Bug 15301. Remove RDF graph from XUL content model construction. Landed XUL_19991005_BRANCH; see branch comments for detailed checkin information. r=shaver,hyatt.

This commit is contained in:
waterson%netscape.com 1999-10-05 21:13:55 +00:00
Родитель 8e2a51ab02
Коммит 14d8b9492e
40 изменённых файлов: 7668 добавлений и 4360 удалений

Просмотреть файл

@ -32,6 +32,7 @@
#include "nsCOMPtr.h"
#include "nsDOMCID.h"
#include "nsDOMEvent.h"
#include "nsForwardReference.h"
#include "nsXULAttributes.h"
#include "nsIXULPopupListener.h"
#include "nsIHTMLContentContainer.h"
@ -54,7 +55,6 @@
#include "nsINameSpaceManager.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIScriptGlobalObject.h"
@ -84,6 +84,7 @@
#include "nsIStyleRule.h"
#include "nsIURL.h"
#include "nsIXULContent.h"
#include "nsIXULDocument.h"
#include "nsXULTreeElement.h"
#include "rdfutil.h"
#include "prlog.h"
@ -334,6 +335,7 @@ public:
NS_IMETHOD SetLazyState(PRInt32 aFlags);
NS_IMETHOD ClearLazyState(PRInt32 aFlags);
NS_IMETHOD GetLazyState(PRInt32 aFlag, PRBool& aValue);
NS_IMETHOD ForceElementToOwnResource(PRBool aForce);
// nsIDOMEventReceiver
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
@ -373,9 +375,6 @@ public:
NS_DECL_IDOMXULELEMENT
// Implementation methods
nsresult GetIdResource(nsIRDFResource** aResult);
nsresult GetRefResource(nsIRDFResource** aResult);
nsresult EnsureContentsGenerated(void) const;
nsresult AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID);
@ -453,6 +452,7 @@ private:
nsIDOMXULElement* mBroadcaster; // [WEAK]
nsCOMPtr<nsIController> mController; // [OWNER]
nsCOMPtr<nsIRDFCompositeDataSource> mDatabase; // [OWNER]
nsCOMPtr<nsIRDFResource> mOwnedResource; // [OWNER]
// An unreferenced bare pointer to an aggregate that can implement
// element-specific APIs.
@ -460,6 +460,29 @@ private:
// The state of our sloth; see nsIXULContent.
PRInt32 mLazyState;
class ObserverForwardReference : public nsForwardReference
{
protected:
nsCOMPtr<nsIDOMElement> mListener;
nsString mTargetID;
nsString mAttributes;
public:
ObserverForwardReference(nsIDOMElement* aListener,
const nsString& aTargetID,
const nsString& aAttributes) :
mListener(aListener),
mTargetID(aTargetID),
mAttributes(aAttributes) {}
virtual ~ObserverForwardReference() {}
virtual Result Resolve();
};
friend class ObserverForwardReference;
};
@ -542,6 +565,44 @@ static EventHandlerMapEntry kEventHandlerMap[] = {
{ nsnull, nsnull, nsnull }
};
////////////////////////////////////////////////////////////////////////
nsForwardReference::Result
RDFElementImpl::ObserverForwardReference::Resolve()
{
nsresult rv;
nsCOMPtr<nsIContent> content = do_QueryInterface(mListener);
if (! content)
return eResolveError;
nsCOMPtr<nsIDocument> doc;
rv = content->GetDocument(*getter_AddRefs(doc));
if (NS_FAILED(rv)) return eResolveError;
nsCOMPtr<nsIDOMXULDocument> xuldoc = do_QueryInterface(doc);
if (! xuldoc)
return eResolveError;
nsCOMPtr<nsIDOMElement> target;
rv = xuldoc->GetElementById(mTargetID, getter_AddRefs(target));
if (NS_FAILED(rv)) return eResolveError;
if (! target)
return eResolveLater;
nsCOMPtr<nsIDOMXULElement> broadcaster = do_QueryInterface(target);
if (! broadcaster)
return eResolveError;
rv = broadcaster->AddBroadcastListener(mAttributes, mListener);
if (NS_FAILED(rv)) return eResolveError;
return eResolveSucceeded;
}
////////////////////////////////////////////////////////////////////////
// RDFElementImpl
@ -1465,6 +1526,24 @@ RDFElementImpl::GetLazyState(PRInt32 aFlag, PRBool& aResult)
return NS_OK;
}
NS_IMETHODIMP
RDFElementImpl::ForceElementToOwnResource(PRBool aForce)
{
nsresult rv;
if (aForce) {
rv = GetResource(getter_AddRefs(mOwnedResource));
if (NS_FAILED(rv)) return rv;
}
else {
// drop reference
mOwnedResource = nsnull;
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsIDOMEventReceiver interface
@ -1691,30 +1770,8 @@ RDFElementImpl::SetDocument(nsIDocument* aDocument, PRBool aDeep)
nsresult rv;
nsCOMPtr<nsIRDFDocument> rdfDoc;
nsCOMPtr<nsIXULDocument> rdfDoc;
if (mDocument) {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
NS_ASSERTION(rdfdoc != nsnull, "ack! not in an RDF document");
if (rdfdoc) {
// Need to do a GetIdResource() here, because changing the document
// may actually change the element's URI.
nsCOMPtr<nsIRDFResource> resource;
GetIdResource(getter_AddRefs(resource));
// Remove this element from the RDF resource-to-element map in
// the old document.
if (resource) {
rv = rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error unmapping resource from element");
}
GetRefResource(getter_AddRefs(resource));
if (resource) {
rv = rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error unmapping resource from element");
}
}
// Release the named reference to the script object so it can
// be garbage collected.
if (mScriptObject) {
@ -1735,28 +1792,6 @@ RDFElementImpl::SetDocument(nsIDocument* aDocument, PRBool aDeep)
mDocument = aDocument; // not refcounted
if (mDocument) {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
NS_ASSERTION(rdfdoc != nsnull, "ack! not in an RDF document");
if (rdfdoc) {
// Need to do a GetIdResource() here, because changing the document
// may actually change the element's URI.
nsCOMPtr<nsIRDFResource> resource;
GetIdResource(getter_AddRefs(resource));
// Add this element to the RDF resource-to-element map in the
// new document.
if (resource) {
rv = rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error mapping resource to element");
}
GetRefResource(getter_AddRefs(resource));
if (resource) {
rv = rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error mapping resource to element");
}
}
// Add a named reference to the script object.
if (mScriptObject) {
nsIScriptContextOwner *owner = mDocument->GetScriptContextOwner();
@ -1859,11 +1894,17 @@ RDFElementImpl::SetParent(nsIContent* aParent)
}
}
else {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
return NS_ERROR_UNEXPECTED;
rdfdoc->AddForwardObserverDecl(listener, elementValue, attributeValue);
ObserverForwardReference* fwdref =
new ObserverForwardReference(listener, elementValue, attributeValue);
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
@ -2268,11 +2309,17 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
}
}
else {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
rdfdoc->AddForwardObserverDecl(this, aValue, "*");
ObserverForwardReference* fwdref =
new ObserverForwardReference(this, aValue, nsAutoString("*"));
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
@ -2347,26 +2394,6 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
NS_IF_RELEASE(popupListener);
}
// Check to see if the REF attribute is being set. If so, we need
// to update the element map. First, remove the old mapping, if
// necessary...
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
nsCOMPtr<nsIRDFResource> resource;
if (aName == kRefAtom) {
GetRefResource(getter_AddRefs(resource));
}
else if (aName == kIdAtom) {
GetIdResource(getter_AddRefs(resource));
}
if (resource) {
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
}
}
// XXX need to check if they're changing an event handler: if so, then we need
// to unhook the old one.
@ -2391,23 +2418,6 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
mAttributes->AppendElement(attr);
}
// Check for REF attribute, part deux. Add the new REF to the map,
// if appropriate.
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
nsCOMPtr<nsIRDFResource> resource;
if (aName == kRefAtom) {
GetRefResource(getter_AddRefs(resource));
}
else if (aName == kIdAtom) {
GetIdResource(getter_AddRefs(resource));
}
if (resource) {
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
}
}
// Check for event handlers and add a script listener if necessary.
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeAtom) {
@ -2529,18 +2539,6 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
else {
rv = NS_CONTENT_ATTR_NO_VALUE;
}
#if 0
if ((aNameSpaceID == kNameSpaceID_None) &&
(attr->mName == kIdAtom))
{
// RDF will treat all document IDs as absolute URIs, so we'll need convert
// a possibly-absolute URI into a relative ID attribute.
NS_ASSERTION(mDocument != nsnull, "not initialized");
if (nsnull != mDocument) {
gXULUtils->MakeElementID(mDocument, attr->mValue, aResult);
}
}
#endif
break;
}
}
@ -3053,15 +3051,25 @@ NS_IMETHODIMP
RDFElementImpl::GetResource(nsIRDFResource** aResource)
{
nsresult rv;
rv = GetRefResource(aResource);
if (NS_FAILED(rv)) return rv;
if (! *aResource) {
rv = GetIdResource(aResource);
nsAutoString id;
rv = GetAttribute(kNameSpaceID_None, kRefAtom, id);
if (NS_FAILED(rv)) return rv;
if (rv != NS_CONTENT_ATTR_HAS_VALUE) {
rv = GetAttribute(kNameSpaceID_None, kIdAtom, id);
if (NS_FAILED(rv)) return rv;
}
}
return NS_OK;
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
rv = gRDFService->GetResource(nsCAutoString(id), aResource);
if (NS_FAILED(rv)) return rv;
}
else {
*aResource = nsnull;
}
return NS_OK;
}
@ -3097,51 +3105,6 @@ RDFElementImpl::SetDatabase(nsIRDFCompositeDataSource* aDatabase)
////////////////////////////////////////////////////////////////////////
// Implementation methods
nsresult
RDFElementImpl::GetIdResource(nsIRDFResource** aResource)
{
if (mAttributes) {
for (PRInt32 i = mAttributes->Count() - 1; i >= 0; --i) {
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
if ((attr->mNameSpaceID == kNameSpaceID_None) &&
(attr->mName == kIdAtom)) {
return gXULUtils->MakeElementResource(mDocument, attr->mValue, aResource);
}
}
}
// No resource associated with this element.
*aResource = nsnull;
return NS_OK;
}
nsresult
RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
{
NS_PRECONDITION(mDocument != nsnull, "not initialized");
if (! mDocument)
return NS_ERROR_NOT_INITIALIZED;
if (mAttributes) {
for (PRInt32 i = mAttributes->Count() - 1; i >= 0; --i) {
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
if (attr->mNameSpaceID != kNameSpaceID_None)
continue;
if (attr->mName != kRefAtom)
continue;
return gXULUtils->MakeElementResource(mDocument, attr->mValue, aResource);
}
}
// If we get here, there was no 'ref' attribute. So return a null resource.
*aResource = nsnull;
return NS_OK;
}
nsresult
RDFElementImpl::EnsureContentsGenerated(void) const
{
@ -3167,7 +3130,7 @@ RDFElementImpl::EnsureContentsGenerated(void) const
// getters if needed.
unconstThis->mLazyState &= ~nsIXULContent::eChildrenMustBeRebuilt;
nsCOMPtr<nsIRDFDocument> rdfDoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfDoc = do_QueryInterface(mDocument);
if (! mDocument)
return NS_OK;

Просмотреть файл

@ -36,10 +36,9 @@ class nsIXULContentSink : public nsIXMLContentSink
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXULCONTENTSINK_IID; return iid; }
NS_IMETHOD Init(nsIDocument* aDocument,
nsIRDFDataSource* aDataSource) = 0;
NS_IMETHOD Init(nsIDocument* aDocument) = 0;
NS_IMETHOD UnblockNextOverlay() = 0;
NS_IMETHOD UnblockNextOverlay() = 0;
NS_IMETHOD UpdateOverlayCounters(PRInt32 aDelta) = 0;
};

Просмотреть файл

@ -0,0 +1,317 @@
/* -*- 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 "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.
*/
/*
Maps IDs to elements.
*/
#include "nsCRT.h"
#include "nsElementMap.h"
#include "nsIContent.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "prlog.h"
#ifdef PR_LOGGING
static PRLogModuleInfo* gMapLog;
#endif
nsElementMap::nsElementMap()
{
// Create a table for mapping IDs to elements in the content tree.
static PRInt32 kInitialResourceTableSize = 1023;
mMap = PL_NewHashTable(kInitialResourceTableSize,
Hash,
Compare,
PL_CompareValues,
nsnull,
nsnull);
NS_ASSERTION(mMap != nsnull, "could not create hash table for resources");
#ifdef PR_LOGGING
if (! gMapLog)
gMapLog = PR_NewLogModule("nsElementMap");
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) created", this));
#endif
}
nsElementMap::~nsElementMap()
{
if (mMap) {
PL_HashTableEnumerateEntries(mMap, ReleaseContentList, nsnull);
PL_HashTableDestroy(mMap);
}
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) destroyed", this));
}
PRIntn
nsElementMap::ReleaseContentList(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure)
{
PRUnichar* id =
NS_REINTERPRET_CAST(PRUnichar*, NS_CONST_CAST(void*, aHashEntry->key));
delete[] id;
ContentListItem* head =
NS_REINTERPRET_CAST(ContentListItem*, aHashEntry->value);
while (head) {
ContentListItem* doomed = head;
head = head->mNext;
delete doomed;
}
return HT_ENUMERATE_NEXT;
}
nsresult
nsElementMap::Add(const nsString& aID, nsIContent* aContent)
{
NS_PRECONDITION(mMap != nsnull, "not initialized");
if (! mMap)
return NS_ERROR_NOT_INITIALIZED;
ContentListItem* head =
(ContentListItem*) PL_HashTableLookup(mMap, aID.GetUnicode());
if (! head) {
head = new ContentListItem(aContent);
if (! head)
return NS_ERROR_OUT_OF_MEMORY;
PRUnichar* key = new PRUnichar[aID.Length() + 1];
if (! key)
return NS_ERROR_OUT_OF_MEMORY;
nsCRT::memcpy(key, aID.GetUnicode(), aID.Length() * sizeof(PRUnichar));
key[aID.Length()] = PRUnichar(0);
PL_HashTableAdd(mMap, key, head);
NS_ADDREF(aContent);
}
else {
while (1) {
if (head->mContent == aContent) {
// This can happen if an element that was created via
// frame construction code is then "appended" to the
// content model with aNotify == PR_TRUE. If you see
// this warning, it's an indication that you're
// unnecessarily notifying the frame system, and
// potentially causing unnecessary reflow.
//NS_ERROR("element was already in the map");
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) dup [%p] <-- %s\n",
this, aContent, (const char*) nsCAutoString(aID)));
return NS_OK;
}
if (! head->mNext)
break;
head = head->mNext;
}
head->mNext = new ContentListItem(aContent);
if (! head->mNext)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(aContent);
}
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) add [%p] <-- %s\n",
this, aContent, (const char*) nsCAutoString(aID)));
return NS_OK;
}
nsresult
nsElementMap::Remove(const nsString& aID, nsIContent* aContent)
{
NS_PRECONDITION(mMap != nsnull, "not initialized");
if (! mMap)
return NS_ERROR_NOT_INITIALIZED;
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) remove [%p] <-- %s\n",
this, aContent, (const char*) nsCAutoString(aID)));
PLHashEntry** hep = PL_HashTableRawLookup(mMap,
Hash(aID.GetUnicode()),
aID.GetUnicode());
// XXX Don't comment out this assert: if you get here, something
// has gone dreadfully, horribly wrong. Curse. Scream. File a bug
// against waterson@netscape.com.
NS_ASSERTION(hep != nsnull && *hep != nsnull, "attempt to remove an element that was never added");
if (!hep || !*hep)
return NS_ERROR_ILLEGAL_VALUE;
ContentListItem* head = NS_REINTERPRET_CAST(ContentListItem*, (*hep)->value);
if (head->mContent == aContent) {
NS_RELEASE(aContent);
ContentListItem* next = head->mNext;
if (next) {
(*hep)->value = next;
}
else {
// It was the last reference in the table
PRUnichar* key = NS_REINTERPRET_CAST(PRUnichar*, NS_CONST_CAST(void*, (*hep)->key));
PL_HashTableRawRemove(mMap, hep, *hep);
delete[] key;
}
delete head;
}
else {
ContentListItem* item = head->mNext;
while (item) {
if (item->mContent == aContent) {
head->mNext = item->mNext;
NS_RELEASE(aContent);
delete item;
break;
}
head = item;
item = item->mNext;
}
}
return NS_OK;
}
nsresult
nsElementMap::Find(const nsString& aID, nsISupportsArray* aResults)
{
NS_PRECONDITION(mMap != nsnull, "not initialized");
if (! mMap)
return NS_ERROR_NOT_INITIALIZED;
aResults->Clear();
ContentListItem* item =
NS_REINTERPRET_CAST(ContentListItem*, PL_HashTableLookup(mMap, aID.GetUnicode()));
while (item) {
aResults->AppendElement(item->mContent);
item = item->mNext;
}
return NS_OK;
}
nsresult
nsElementMap::FindFirst(const nsString& aID, nsIContent** aResult)
{
NS_PRECONDITION(mMap != nsnull, "not initialized");
if (! mMap)
return NS_ERROR_NOT_INITIALIZED;
ContentListItem* item =
NS_REINTERPRET_CAST(ContentListItem*, PL_HashTableLookup(mMap, aID.GetUnicode()));
if (item) {
*aResult = item->mContent;
NS_ADDREF(*aResult);
}
else {
*aResult = nsnull;
}
return NS_OK;
}
nsresult
nsElementMap::Enumerate(nsElementMapEnumerator aEnumerator, void* aClosure)
{
EnumerateClosure closure = { aEnumerator, aClosure };
PL_HashTableEnumerateEntries(mMap, EnumerateImpl, &closure);
return NS_OK;
}
PRIntn
nsElementMap::EnumerateImpl(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure)
{
EnumerateClosure* closure = NS_REINTERPRET_CAST(EnumerateClosure*, aClosure);
const PRUnichar* id =
NS_REINTERPRET_CAST(const PRUnichar*, aHashEntry->key);
ContentListItem** link =
NS_REINTERPRET_CAST(ContentListItem**, &aHashEntry->value);
ContentListItem* item = *link;
while (item) {
PRIntn result = (*closure->mEnumerator)(id, item->mContent, closure->mClosure);
if (result == HT_ENUMERATE_REMOVE) {
NS_RELEASE(item->mContent);
*link = item->mNext;
if ((! *link) && (link == NS_REINTERPRET_CAST(ContentListItem**, &aHashEntry->value))) {
PRUnichar* key = NS_CONST_CAST(PRUnichar*, id);
delete[] key;
return HT_ENUMERATE_REMOVE;
}
}
else {
link = &item->mNext;
}
item = item->mNext;
}
return HT_ENUMERATE_NEXT;
}
PLHashNumber
nsElementMap::Hash(const void* aKey)
{
PLHashNumber result = 0;
const PRUnichar* s = NS_REINTERPRET_CAST(const PRUnichar*, aKey);
while (*s != nsnull) {
result = (result >> 28) ^ (result << 4) ^ *s;
++s;
}
return result;
}
PRIntn
nsElementMap::Compare(const void* aLeft, const void* aRight)
{
return 0 == nsCRT::strcmp(NS_REINTERPRET_CAST(const PRUnichar*, aLeft),
NS_REINTERPRET_CAST(const PRUnichar*, aRight));
}

Просмотреть файл

@ -0,0 +1,93 @@
/* -*- 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 "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.
*/
/*
Maintains one-to-many mapping between element IDs and content
nodes.
*/
#ifndef nsElementMap_h__
#define nsElementMap_h__
#include "nscore.h"
#include "nsError.h"
#include "plhash.h"
class nsString;
class nsIContent;
class nsISupportsArray;
class nsElementMap
{
private:
PLHashTable* mMap;
class ContentListItem {
public:
ContentListItem(nsIContent* aContent)
: mNext(nsnull), mContent(aContent) {}
ContentListItem* mNext;
nsIContent* mContent;
};
static PLHashNumber
Hash(const void* akey);
static PRIntn
Compare(const void* aLeft, const void* aRight);
static PRIntn
ReleaseContentList(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure);
public:
nsElementMap(void);
virtual ~nsElementMap();
nsresult
Add(const nsString& aID, nsIContent* aContent);
nsresult
Remove(const nsString& aID, nsIContent* aContent);
nsresult
Find(const nsString& aID, nsISupportsArray* aResults);
nsresult
FindFirst(const nsString& aID, nsIContent** aContent);
typedef PRIntn (*nsElementMapEnumerator)(const nsString& aID,
nsIContent* aElement,
void* aClosure);
nsresult
Enumerate(nsElementMapEnumerator aEnumerator, void* aClosure);
private:
struct EnumerateClosure {
nsElementMapEnumerator mEnumerator;
void* mClosure;
};
static PRIntn
EnumerateImpl(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure);
};
#endif // nsElementMap_h__

Просмотреть файл

@ -0,0 +1,46 @@
/* -*- 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 "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.
*/
#ifndef nsForwardReference_h__
#define nsForwardReference_h__
class nsForwardReference
{
protected:
nsForwardReference() {}
public:
virtual ~nsForwardReference() {}
enum Result {
eResolveSucceeded, // resolution succeeded, i'm done
eResolveLater, // couldn't resolve, try me later
eResolveError // something bad happened, don't try again
};
/**
* Attempt to resolve the forward reference.
*
* @return a Result that tells the resolver how to treat
* the reference.
*/
virtual Result Resolve() = 0;
};
#endif // nsForwardReference_h__

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -20,7 +20,7 @@
/*
A content model builder interface. An object that implements this
interface is associated with an nsIRDFDocument object to construct
interface is associated with an nsIXULDocument object to construct
an NGLayout content model.
*/
@ -33,7 +33,7 @@
class nsIAtom;
class nsIContent;
class nsIRDFCompositeDataSource;
class nsIRDFDocument;
class nsIXULDocument;
class nsIRDFNode;
class nsIRDFResource;
@ -50,7 +50,7 @@ public:
* Point the content model builder to the document. The content model
* builder must not reference count the document.
*/
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument) = 0;
NS_IMETHOD SetDocument(nsIXULDocument* aDocument) = 0;
NS_IMETHOD SetDataBase(nsIRDFCompositeDataSource* aDataBase) = 0;
NS_IMETHOD GetDataBase(nsIRDFCompositeDataSource** aDataBase) = 0;
@ -83,17 +83,6 @@ public:
* Rebuild the contents of a container.
*/
NS_IMETHOD RebuildContainer(nsIContent* aContainer) = 0;
/**
* Construct an element. This is exposed as a public method,
* because the document implementation may need to call it to
* support the DOM's document.createElement() method.
*/
NS_IMETHOD CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIRDFResource* aResource,
nsIContent** aResult) = 0;
};
extern nsresult NS_NewXULTemplateBuilder(nsIRDFContentModelBuilder** aResult);

Просмотреть файл

@ -30,7 +30,6 @@
#include "nsINameSpaceManager.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFObserver.h"
#include "nsIRDFService.h"

Просмотреть файл

@ -50,7 +50,7 @@
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFDocument.h"
#include "nsIXULDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFObserver.h"
#include "nsIRDFRemoteDataSource.h"
@ -126,7 +126,7 @@ public:
NS_DECL_ISUPPORTS
// nsIRDFContentModelBuilder interface
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
NS_IMETHOD SetDocument(nsIXULDocument* aDocument);
NS_IMETHOD SetDataBase(nsIRDFCompositeDataSource* aDataBase);
NS_IMETHOD GetDataBase(nsIRDFCompositeDataSource** aDataBase);
NS_IMETHOD CreateRootContent(nsIRDFResource* aResource);
@ -135,10 +135,6 @@ public:
NS_IMETHOD OpenContainer(nsIContent* aContainer);
NS_IMETHOD CloseContainer(nsIContent* aContainer);
NS_IMETHOD RebuildContainer(nsIContent* aContainer);
NS_IMETHOD CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIRDFResource* aResource,
nsIContent** aResult);
// nsIRDFObserver interface
NS_IMETHOD OnAssert(nsIRDFResource* aSource,
@ -270,8 +266,16 @@ public:
nsresult
AddDatabasePropertyToHTMLElement(nsIContent* aElement, nsIRDFCompositeDataSource* aDataBase);
nsresult
GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements);
nsresult
CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIContent** aResult);
protected:
nsIRDFDocument* mDocument; // [WEAK]
nsIXULDocument* mDocument; // [WEAK]
// We are an observer of the composite datasource. The cycle is
// broken by out-of-band SetDataBase(nsnull) call when document is
@ -613,7 +617,7 @@ RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
// nsIRDFContentModelBuilder methods
NS_IMETHODIMP
RDFGenericBuilderImpl::SetDocument(nsIRDFDocument* aDocument)
RDFGenericBuilderImpl::SetDocument(nsIXULDocument* aDocument)
{
// note: null now allowed, it indicates document going away
@ -912,74 +916,6 @@ RDFGenericBuilderImpl::RebuildContainer(nsIContent* aElement)
}
NS_IMETHODIMP
RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIRDFResource* aResource,
nsIContent** aResult)
{
nsresult rv;
nsCOMPtr<nsIContent> result;
if (aNameSpaceID == kNameSpaceID_HTML) {
nsCOMPtr<nsIHTMLContent> element;
const PRUnichar *tagName;
aTag->GetUnicode(&tagName);
rv = gHTMLElementFactory->CreateInstanceByTag(tagName, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
result = do_QueryInterface(element);
if (! result)
return NS_ERROR_UNEXPECTED;
}
else {
rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
if (aResource) {
const char *uri;
rv = aResource->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
PRUnichar buf[128];
nsAutoString id(CBufDescriptor(buf, PR_TRUE, sizeof(buf) / sizeof(PRUnichar), 0));
#if 0 // XXX c'mon, this URI is _never_ going to be relative to the document!
rv = gXULUtils->MakeElementID(doc, nsAutoString(uri), id);
if (NS_FAILED(rv)) return rv;
#endif
id = uri;
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
if (NS_FAILED(rv)) return rv;
}
rv = result->SetDocument(doc, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
if (NS_FAILED(rv)) return rv;
if (aResource && aNameSpaceID == kNameSpaceID_HTML) {
// If this is an HTML element, then explicitly add it to the
// map. (XUL elements don't have to do this because their
// SetDocument() call does the magic.) Don't worry: the
// document observer methods are on the lookout to update the
// map for "attribute changed" calls that monkey with the 'id'
// or 'ref' parameters.
rv = mDocument->AddElementForResource(aResource, result);
if (NS_FAILED(rv)) return rv;
}
*aResult = result;
NS_ADDREF(*aResult);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsIRDFObserver interface
@ -1004,9 +940,9 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) return rv;
PRUint32 cnt;
rv = elements->Count(&cnt);
@ -1122,7 +1058,7 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
@ -1246,7 +1182,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
@ -1781,9 +1717,39 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
else if (isResourceElement) {
// It's the "resource" element
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(realKid));
if (NS_FAILED(rv)) return rv;
const char *uri;
rv = aChild->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
nsAutoString id(uri);
rv = realKid->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
if (NS_FAILED(rv)) return rv;
if (! aNotify) {
// XUL document will watch us, and take care of making
// sure that we get added to or removed from the
// element map if aNotify is true. If not, we gotta do
// it ourselves. Yay.
rv = mDocument->AddElementForID(id, realKid);
if (NS_FAILED(rv)) return rv;
}
// XXX Hackery to ensure that mailnews works. Force the
// element to hold a reference to the
// resource. Unfortunately, this'll break for HTML
// elements.
{
nsCOMPtr<nsIXULContent> xulele = do_QueryInterface(realKid);
if (xulele) {
xulele->ForceElementToOwnResource(PR_TRUE);
}
}
if (IsContainer(tmplKid, aChild)) {
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
if (NS_FAILED(rv)) return rv;
@ -1823,7 +1789,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
else {
// It's just a generic element. Create it!
rv = CreateElement(nameSpaceID, tag, nsnull, getter_AddRefs(realKid));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(realKid));
if (NS_FAILED(rv)) return rv;
}
@ -2146,7 +2112,7 @@ RDFGenericBuilderImpl::RemoveWidgetItem(nsIContent* aElement,
rv = NS_NewISupportsArray(getter_AddRefs(elements));
if (NS_FAILED(rv)) return rv;
rv = mDocument->GetElementsForResource(aValue, elements);
rv = GetElementsForResource(aValue, elements);
if (NS_FAILED(rv)) return rv;
PRUint32 cnt;
@ -2362,7 +2328,7 @@ RDFGenericBuilderImpl::EnsureElementHasGenericChild(nsIContent* parent,
// we need to construct a new child element.
nsCOMPtr<nsIContent> element;
rv = CreateElement(nameSpaceID, tag, nsnull, getter_AddRefs(element));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
// XXX Note that the notification ensures we won't batch insertions! This could be bad! - Dave
@ -2918,3 +2884,59 @@ RDFGenericBuilderImpl::AddDatabasePropertyToHTMLElement(nsIContent* aElement, ns
return NS_OK;
}
nsresult
RDFGenericBuilderImpl::GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements)
{
nsresult rv;
const char *uri;
rv = aResource->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
rv = mDocument->GetElementsForID(nsAutoString(uri), aElements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsresult
RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIContent** aResult)
{
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
if (! doc)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
nsCOMPtr<nsIContent> result;
if (aNameSpaceID == kNameSpaceID_HTML) {
nsCOMPtr<nsIHTMLContent> element;
const PRUnichar *tagName;
aTag->GetUnicode(&tagName);
rv = gHTMLElementFactory->CreateInstanceByTag(tagName, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
result = do_QueryInterface(element);
if (! result)
return NS_ERROR_UNEXPECTED;
}
else {
rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
}
rv = result->SetDocument(doc, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
if (NS_FAILED(rv)) return rv;
*aResult = result;
NS_ADDREF(*aResult);
return NS_OK;
}

Просмотреть файл

@ -78,10 +78,6 @@
#define NS_RDFCONTENTSINK_CID \
{ 0x958b101, 0x9ada, 0x11d2, { 0x8e, 0xbc, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {E45313F0-B59C-11d2-A68C-00104BDE6048}
#define NS_RDFXULBUILDER_CID \
{ 0xe45313f0, 0xb59c, 0x11d2, { 0xa6, 0x8c, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
// {CE058B21-BA9C-11d2-BF86-00105A1B0627}
#define NS_XULCONTENTSINK_CID \
{ 0xce058b21, 0xba9c, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }

Просмотреть файл

@ -25,7 +25,6 @@
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFContentSink.h"
#include "nsIRDFDocument.h"
#include "nsIRDFService.h"
#include "nsIXULContentSink.h"
#include "nsISupports.h"
@ -36,6 +35,7 @@
#include "nsIComponentManager.h"
#include "rdf.h"
#include "nsIXULContentUtils.h"
#include "nsIXULDocument.h"
#include "nsIXULSortService.h"
#include "nsIXULDocumentInfo.h"
#include "nsIXULPopupListener.h"
@ -61,7 +61,6 @@ static NS_DEFINE_CID(kRDFFTPDataSourceCID, NS_RDFFTPDATASOURCE_CI
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
static NS_DEFINE_CID(kRDFXULBuilderCID, NS_RDFXULBUILDER_CID);
static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID);
static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
static NS_DEFINE_CID(kXULDocumentCID, NS_XULDOCUMENT_CID);
@ -118,10 +117,9 @@ MAKE_CTOR(RDFCompositeDataSource,RDFCompositeDataSource,RDFCompositeDataSource)
MAKE_CTOR(RDFContainer,RDFContainer,RDFContainer)
MAKE_CTOR(RDFContainerUtils,RDFContainerUtils,RDFContainerUtils)
MAKE_CTOR(XULDocument,XULDocument,RDFDocument)
MAKE_CTOR(XULDocument,XULDocument,XULDocument)
MAKE_CTOR(XULDocumentInfo,XULDocumentInfo,XULDocumentInfo)
MAKE_CTOR(XULTemplateBuilder,XULTemplateBuilder,RDFContentModelBuilder)
MAKE_CTOR(RDFXULBuilder,RDFXULBuilder,RDFContentModelBuilder)
MAKE_CTOR(RDFContentSink,RDFContentSink,RDFContentSink)
MAKE_CTOR(XULContentSink,XULContentSink,XULContentSink)
@ -227,9 +225,6 @@ nsRDFModule::GetClassObject(nsIComponentManager *aCompMgr,
else if (aClass.Equals(kXULTemplateBuilderCID)) {
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewXULTemplateBuilder);
}
else if (aClass.Equals(kRDFXULBuilderCID)) {
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewRDFXULBuilder);
}
else if (aClass.Equals(kXULContentSinkCID)) {
rv = NS_NewGenericFactory(getter_AddRefs(fact), CreateNewXULContentSink);
}
@ -309,8 +304,6 @@ static Components gComponents[] = {
NS_RDF_PROGID "/xul-sort-service", },
{ "XUL Template Builder", &kXULTemplateBuilderCID,
NS_RDF_PROGID "/xul-template-builder", },
{ "RDF XUL Builder", &kRDFXULBuilderCID,
NS_RDF_PROGID "/xul-builder", },
{ "XUL Content Sink", &kXULContentSinkCID,
NS_RDF_PROGID "/xul-content-sink", },
{ "XUL Document", &kXULDocumentCID,

Просмотреть файл

@ -2,10 +2,9 @@ nsIDOMXULCommandDispatcher.h
nsIDOMXULDocument.h
nsIDOMXULElement.h
nsIDOMXULTreeElement.h
nsIRDFContentModelBuilder.h
nsIRDFDocument.h
nsIXULParentDocument.h
nsIXULChildDocument.h
nsIXULContentSink.h
nsIXULContentUtils.h
nsIXULDocumentInfo.h
nsIXULPopupListener.h

Просмотреть файл

@ -28,10 +28,9 @@ EXPORTS = \
nsIDOMXULDocument.h \
nsIDOMXULElement.h \
nsIDOMXULTreeElement.h \
nsIRDFContentModelBuilder.h \
nsIRDFDocument.h \
nsIXULParentDocument.h \
nsIXULChildDocument.h \
nsIXULContentSink.h \
nsIXULDocumentInfo.h \
nsIXULPopupListener.h \
nsIDOMXULCommandDispatcher.h \

Просмотреть файл

@ -24,10 +24,9 @@ EXPORTS = \
nsIDOMXULDocument.h \
nsIDOMXULElement.h \
nsIDOMXULTreeElement.h \
nsIRDFContentModelBuilder.h \
nsIRDFDocument.h \
nsIXULParentDocument.h \
nsIXULChildDocument.h \
nsIXULContentSink.h \
nsIXULDocumentInfo.h \
nsIXULPopupListener.h \
nsIDOMXULCommandDispatcher.h \

Просмотреть файл

@ -0,0 +1,50 @@
/* -*- 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 "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.
*/
#ifndef nsIXULContentSink_h__
#define nsIXULContentSink_h__
#include "nsIXMLContentSink.h"
class nsIDocument;
class nsIRDFDataSource;
// {E49AA620-C16C-11d2-A6AA-00104BDE6048}
#define NS_IXULCONTENTSINK_IID \
{ 0xe49aa620, 0xc16c, 0x11d2, { 0xa6, 0xaa, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
class nsIXULContentSink : public nsIXMLContentSink
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXULCONTENTSINK_IID; return iid; }
NS_IMETHOD Init(nsIDocument* aDocument) = 0;
NS_IMETHOD UnblockNextOverlay() = 0;
NS_IMETHOD UpdateOverlayCounters(PRInt32 aDelta) = 0;
};
nsresult
NS_NewXULContentSink(nsIXULContentSink** aResult);
#endif // nsIXULContentSink_h__

Просмотреть файл

@ -34,9 +34,6 @@ public:
// Used for XUL fragment child documents
NS_IMETHOD GetContentViewerContainer(nsIContentViewerContainer** aContainer) = 0;
NS_IMETHOD GetCommand(nsString& aCommand) = 0;
// Used for XUL popup child documents
NS_IMETHOD CreatePopupDocument(nsIContent* aPopupElement, nsIDocument** aResult) = 0;
};
#endif // nsIXULParentDocument_h__

Просмотреть файл

@ -28,6 +28,7 @@ LIBRARY_NAME = rdfcontent_s
REQUIRES = dom js netlib rdf raptor xpcom locale
CPPSRCS = \
nsElementMap.cpp \
nsJSXULDocument.cpp \
nsJSXULElement.cpp \
nsJSXULCommandDispatcher.cpp \
@ -35,8 +36,8 @@ CPPSRCS = \
nsRDFDOMNodeList.cpp \
nsRDFElement.cpp \
nsRDFGenericBuilder.cpp \
nsRDFXULBuilder.cpp \
nsXULAttributes.cpp \
nsXULContentSink.cpp \
nsXULContentUtils.cpp \
nsXULDocument.cpp \
nsXULSortService.cpp \

Просмотреть файл

@ -27,19 +27,20 @@ LCFLAGS = \
$(NULL)
CPP_OBJS=\
.\$(OBJDIR)\nsJSXULCommandDispatcher.obj \
.\$(OBJDIR)\nsElementMap.obj \
.\$(OBJDIR)\nsJSXULCommandDispatcher.obj \
.\$(OBJDIR)\nsRDFGenericBuilder.obj \
.\$(OBJDIR)\nsXULAttributes.obj \
.\$(OBJDIR)\nsXULCommandDispatcher.obj \
.\$(OBJDIR)\nsXULCommandDispatcher.obj \
.\$(OBJDIR)\nsXULPopupListener.obj \
.\$(OBJDIR)\nsJSXULDocument.obj \
.\$(OBJDIR)\nsJSXULElement.obj \
.\$(OBJDIR)\nsJSXULTreeElement.obj \
.\$(OBJDIR)\nsRDFDOMNodeList.obj \
.\$(OBJDIR)\nsRDFElement.obj \
.\$(OBJDIR)\nsRDFXULBuilder.obj \
.\$(OBJDIR)\nsXULDocument.obj \
.\$(OBJDIR)\nsXULContentUtils.obj \
.\$(OBJDIR)\nsXULContentSink.obj \
.\$(OBJDIR)\nsXULDocument.obj \
.\$(OBJDIR)\nsXULDocumentInfo.obj \
.\$(OBJDIR)\nsXULKeyListener.obj \
.\$(OBJDIR)\nsXULSortService.obj \

Просмотреть файл

@ -0,0 +1,317 @@
/* -*- 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 "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.
*/
/*
Maps IDs to elements.
*/
#include "nsCRT.h"
#include "nsElementMap.h"
#include "nsIContent.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "prlog.h"
#ifdef PR_LOGGING
static PRLogModuleInfo* gMapLog;
#endif
nsElementMap::nsElementMap()
{
// Create a table for mapping IDs to elements in the content tree.
static PRInt32 kInitialResourceTableSize = 1023;
mMap = PL_NewHashTable(kInitialResourceTableSize,
Hash,
Compare,
PL_CompareValues,
nsnull,
nsnull);
NS_ASSERTION(mMap != nsnull, "could not create hash table for resources");
#ifdef PR_LOGGING
if (! gMapLog)
gMapLog = PR_NewLogModule("nsElementMap");
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) created", this));
#endif
}
nsElementMap::~nsElementMap()
{
if (mMap) {
PL_HashTableEnumerateEntries(mMap, ReleaseContentList, nsnull);
PL_HashTableDestroy(mMap);
}
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) destroyed", this));
}
PRIntn
nsElementMap::ReleaseContentList(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure)
{
PRUnichar* id =
NS_REINTERPRET_CAST(PRUnichar*, NS_CONST_CAST(void*, aHashEntry->key));
delete[] id;
ContentListItem* head =
NS_REINTERPRET_CAST(ContentListItem*, aHashEntry->value);
while (head) {
ContentListItem* doomed = head;
head = head->mNext;
delete doomed;
}
return HT_ENUMERATE_NEXT;
}
nsresult
nsElementMap::Add(const nsString& aID, nsIContent* aContent)
{
NS_PRECONDITION(mMap != nsnull, "not initialized");
if (! mMap)
return NS_ERROR_NOT_INITIALIZED;
ContentListItem* head =
(ContentListItem*) PL_HashTableLookup(mMap, aID.GetUnicode());
if (! head) {
head = new ContentListItem(aContent);
if (! head)
return NS_ERROR_OUT_OF_MEMORY;
PRUnichar* key = new PRUnichar[aID.Length() + 1];
if (! key)
return NS_ERROR_OUT_OF_MEMORY;
nsCRT::memcpy(key, aID.GetUnicode(), aID.Length() * sizeof(PRUnichar));
key[aID.Length()] = PRUnichar(0);
PL_HashTableAdd(mMap, key, head);
NS_ADDREF(aContent);
}
else {
while (1) {
if (head->mContent == aContent) {
// This can happen if an element that was created via
// frame construction code is then "appended" to the
// content model with aNotify == PR_TRUE. If you see
// this warning, it's an indication that you're
// unnecessarily notifying the frame system, and
// potentially causing unnecessary reflow.
//NS_ERROR("element was already in the map");
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) dup [%p] <-- %s\n",
this, aContent, (const char*) nsCAutoString(aID)));
return NS_OK;
}
if (! head->mNext)
break;
head = head->mNext;
}
head->mNext = new ContentListItem(aContent);
if (! head->mNext)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(aContent);
}
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) add [%p] <-- %s\n",
this, aContent, (const char*) nsCAutoString(aID)));
return NS_OK;
}
nsresult
nsElementMap::Remove(const nsString& aID, nsIContent* aContent)
{
NS_PRECONDITION(mMap != nsnull, "not initialized");
if (! mMap)
return NS_ERROR_NOT_INITIALIZED;
PR_LOG(gMapLog, PR_LOG_ALWAYS,
("xulelemap(%p) remove [%p] <-- %s\n",
this, aContent, (const char*) nsCAutoString(aID)));
PLHashEntry** hep = PL_HashTableRawLookup(mMap,
Hash(aID.GetUnicode()),
aID.GetUnicode());
// XXX Don't comment out this assert: if you get here, something
// has gone dreadfully, horribly wrong. Curse. Scream. File a bug
// against waterson@netscape.com.
NS_ASSERTION(hep != nsnull && *hep != nsnull, "attempt to remove an element that was never added");
if (!hep || !*hep)
return NS_ERROR_ILLEGAL_VALUE;
ContentListItem* head = NS_REINTERPRET_CAST(ContentListItem*, (*hep)->value);
if (head->mContent == aContent) {
NS_RELEASE(aContent);
ContentListItem* next = head->mNext;
if (next) {
(*hep)->value = next;
}
else {
// It was the last reference in the table
PRUnichar* key = NS_REINTERPRET_CAST(PRUnichar*, NS_CONST_CAST(void*, (*hep)->key));
PL_HashTableRawRemove(mMap, hep, *hep);
delete[] key;
}
delete head;
}
else {
ContentListItem* item = head->mNext;
while (item) {
if (item->mContent == aContent) {
head->mNext = item->mNext;
NS_RELEASE(aContent);
delete item;
break;
}
head = item;
item = item->mNext;
}
}
return NS_OK;
}
nsresult
nsElementMap::Find(const nsString& aID, nsISupportsArray* aResults)
{
NS_PRECONDITION(mMap != nsnull, "not initialized");
if (! mMap)
return NS_ERROR_NOT_INITIALIZED;
aResults->Clear();
ContentListItem* item =
NS_REINTERPRET_CAST(ContentListItem*, PL_HashTableLookup(mMap, aID.GetUnicode()));
while (item) {
aResults->AppendElement(item->mContent);
item = item->mNext;
}
return NS_OK;
}
nsresult
nsElementMap::FindFirst(const nsString& aID, nsIContent** aResult)
{
NS_PRECONDITION(mMap != nsnull, "not initialized");
if (! mMap)
return NS_ERROR_NOT_INITIALIZED;
ContentListItem* item =
NS_REINTERPRET_CAST(ContentListItem*, PL_HashTableLookup(mMap, aID.GetUnicode()));
if (item) {
*aResult = item->mContent;
NS_ADDREF(*aResult);
}
else {
*aResult = nsnull;
}
return NS_OK;
}
nsresult
nsElementMap::Enumerate(nsElementMapEnumerator aEnumerator, void* aClosure)
{
EnumerateClosure closure = { aEnumerator, aClosure };
PL_HashTableEnumerateEntries(mMap, EnumerateImpl, &closure);
return NS_OK;
}
PRIntn
nsElementMap::EnumerateImpl(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure)
{
EnumerateClosure* closure = NS_REINTERPRET_CAST(EnumerateClosure*, aClosure);
const PRUnichar* id =
NS_REINTERPRET_CAST(const PRUnichar*, aHashEntry->key);
ContentListItem** link =
NS_REINTERPRET_CAST(ContentListItem**, &aHashEntry->value);
ContentListItem* item = *link;
while (item) {
PRIntn result = (*closure->mEnumerator)(id, item->mContent, closure->mClosure);
if (result == HT_ENUMERATE_REMOVE) {
NS_RELEASE(item->mContent);
*link = item->mNext;
if ((! *link) && (link == NS_REINTERPRET_CAST(ContentListItem**, &aHashEntry->value))) {
PRUnichar* key = NS_CONST_CAST(PRUnichar*, id);
delete[] key;
return HT_ENUMERATE_REMOVE;
}
}
else {
link = &item->mNext;
}
item = item->mNext;
}
return HT_ENUMERATE_NEXT;
}
PLHashNumber
nsElementMap::Hash(const void* aKey)
{
PLHashNumber result = 0;
const PRUnichar* s = NS_REINTERPRET_CAST(const PRUnichar*, aKey);
while (*s != nsnull) {
result = (result >> 28) ^ (result << 4) ^ *s;
++s;
}
return result;
}
PRIntn
nsElementMap::Compare(const void* aLeft, const void* aRight)
{
return 0 == nsCRT::strcmp(NS_REINTERPRET_CAST(const PRUnichar*, aLeft),
NS_REINTERPRET_CAST(const PRUnichar*, aRight));
}

Просмотреть файл

@ -0,0 +1,93 @@
/* -*- 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 "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.
*/
/*
Maintains one-to-many mapping between element IDs and content
nodes.
*/
#ifndef nsElementMap_h__
#define nsElementMap_h__
#include "nscore.h"
#include "nsError.h"
#include "plhash.h"
class nsString;
class nsIContent;
class nsISupportsArray;
class nsElementMap
{
private:
PLHashTable* mMap;
class ContentListItem {
public:
ContentListItem(nsIContent* aContent)
: mNext(nsnull), mContent(aContent) {}
ContentListItem* mNext;
nsIContent* mContent;
};
static PLHashNumber
Hash(const void* akey);
static PRIntn
Compare(const void* aLeft, const void* aRight);
static PRIntn
ReleaseContentList(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure);
public:
nsElementMap(void);
virtual ~nsElementMap();
nsresult
Add(const nsString& aID, nsIContent* aContent);
nsresult
Remove(const nsString& aID, nsIContent* aContent);
nsresult
Find(const nsString& aID, nsISupportsArray* aResults);
nsresult
FindFirst(const nsString& aID, nsIContent** aContent);
typedef PRIntn (*nsElementMapEnumerator)(const nsString& aID,
nsIContent* aElement,
void* aClosure);
nsresult
Enumerate(nsElementMapEnumerator aEnumerator, void* aClosure);
private:
struct EnumerateClosure {
nsElementMapEnumerator mEnumerator;
void* mClosure;
};
static PRIntn
EnumerateImpl(PLHashEntry* aHashEntry, PRIntn aIndex, void* aClosure);
};
#endif // nsElementMap_h__

Просмотреть файл

@ -0,0 +1,46 @@
/* -*- 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 "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.
*/
#ifndef nsForwardReference_h__
#define nsForwardReference_h__
class nsForwardReference
{
protected:
nsForwardReference() {}
public:
virtual ~nsForwardReference() {}
enum Result {
eResolveSucceeded, // resolution succeeded, i'm done
eResolveLater, // couldn't resolve, try me later
eResolveError // something bad happened, don't try again
};
/**
* Attempt to resolve the forward reference.
*
* @return a Result that tells the resolver how to treat
* the reference.
*/
virtual Result Resolve() = 0;
};
#endif // nsForwardReference_h__

Просмотреть файл

@ -0,0 +1,91 @@
/* -*- 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 "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.
*/
/*
A content model builder interface. An object that implements this
interface is associated with an nsIXULDocument object to construct
an NGLayout content model.
*/
#ifndef nsIRDFContentModelBuilder_h__
#define nsIRDFContentModelBuilder_h__
#include "nsISupports.h"
class nsIAtom;
class nsIContent;
class nsIRDFCompositeDataSource;
class nsIXULDocument;
class nsIRDFNode;
class nsIRDFResource;
// {541AFCB0-A9A3-11d2-8EC5-00805F29F370}
#define NS_IRDFCONTENTMODELBUILDER_IID \
{ 0x541afcb0, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
class nsIRDFContentModelBuilder : public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IRDFCONTENTMODELBUILDER_IID; return iid; }
/**
* Point the content model builder to the document. The content model
* builder must not reference count the document.
*/
NS_IMETHOD SetDocument(nsIXULDocument* aDocument) = 0;
NS_IMETHOD SetDataBase(nsIRDFCompositeDataSource* aDataBase) = 0;
NS_IMETHOD GetDataBase(nsIRDFCompositeDataSource** aDataBase) = 0;
/**
* Set the root element from which this content model will
* operate.
*/
NS_IMETHOD CreateRootContent(nsIRDFResource* aResource) = 0;
NS_IMETHOD SetRootContent(nsIContent* aElement) = 0;
/**
* Construct the contents for a container element.
*/
NS_IMETHOD CreateContents(nsIContent* aElement) = 0;
/**
* 'Open' a container element that was closed before. This gives
* the container a chance to populate its contents.
*/
NS_IMETHOD OpenContainer(nsIContent* aContainer) = 0;
/**
* 'Close' an open container. This gives the container a chance to
* release unused content nodes.
*/
NS_IMETHOD CloseContainer(nsIContent* aContainer) = 0;
/**
* Rebuild the contents of a container.
*/
NS_IMETHOD RebuildContainer(nsIContent* aContainer) = 0;
};
extern nsresult NS_NewXULTemplateBuilder(nsIRDFContentModelBuilder** aResult);
extern nsresult NS_NewRDFXULBuilder(nsIRDFContentModelBuilder** aResult);
#endif // nsIRDFContentModelBuilder_h__

Просмотреть файл

@ -84,6 +84,13 @@ public:
* @aResult the result
*/
NS_IMETHOD GetLazyState(PRInt32 aFlag, PRBool& aResult) = 0;
/**
* Evil rotten hack to make mailnews work. They assume that we
* keep a reference to their resource objects. If you think you
* should call this method, think again. You shouldn't.
*/
NS_IMETHOD ForceElementToOwnResource(PRBool aForce) = 0;
};
#endif // nsIXULContent_h__

Просмотреть файл

@ -19,7 +19,7 @@
/*
An RDF-specific extension to nsIXMLDocument. Includes methods for
An XUL-specific extension to nsIXMLDocument. Includes methods for
setting the root resource of the document content model, a factory
method for constructing the children of a node, etc.
@ -27,13 +27,14 @@
*/
#ifndef nsIRDFDocument_h___
#define nsIRDFDocument_h___
#ifndef nsIXULDocument_h___
#define nsIXULDocument_h___
class nsIContent; // XXX nsIXMLDocument.h is bad and doesn't declare this class...
#include "nsIXMLDocument.h"
class nsForwardReference;
class nsIAtom;
class nsIRDFCompositeDataSource;
class nsIRDFContent;
@ -53,43 +54,31 @@ class nsIDOMHTMLFormElement;
class nsIRDFDataSource;
class nsIRDFDocument : public nsIXMLDocument
class nsIXULDocument : public nsIXMLDocument
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IRDFDOCUMENT_IID; return iid; }
/**
* Set the document's "root" resource.
*/
NS_IMETHOD SetRootResource(nsIRDFResource* aResource) = 0;
NS_IMETHOD SplitProperty(nsIRDFResource* aResource,
PRInt32* aNameSpaceID,
nsIAtom** aTag) = 0;
// The resource-to-element map is a one-to-many mapping of RDF
// resources to content elements.
/**
* Add an entry to the resource-to-element map.
* Add an entry to the ID-to-element map.
*/
NS_IMETHOD AddElementForResource(nsIRDFResource* aResource, nsIContent* aElement) = 0;
NS_IMETHOD AddElementForID(const nsString& aID, nsIContent* aElement) = 0;
/**
* Remove an entry from the resource-to-element map.
* Remove an entry from the ID-to-element map.
*/
NS_IMETHOD RemoveElementForResource(nsIRDFResource* aResource, nsIContent* aElement) = 0;
NS_IMETHOD RemoveElementForID(const nsString& aID, nsIContent* aElement) = 0;
/**
* Get the elements for a particular resource in the resource-to-element
* map. The nsISupportsArray will be truncated and filled in with
* nsIContent pointers.
*/
NS_IMETHOD GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements) = 0;
NS_IMETHOD GetElementsForID(const nsString& aID, nsISupportsArray* aElements) = 0;
/**
* Create the contents for an element.
*/
NS_IMETHOD CreateContents(nsIContent* aElement) = 0;
/**
@ -98,10 +87,8 @@ public:
NS_IMETHOD AddContentModelBuilder(nsIRDFContentModelBuilder* aBuilder) = 0;
/**
* Get the RDF datasource that represents the document.
* Manipulate the XUL document's form element
*/
NS_IMETHOD GetDocumentDataSource(nsIRDFDataSource** aDatasource) = 0;
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm) = 0;
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm) = 0;
@ -109,14 +96,12 @@ public:
* Add a "forward declaration" of a XUL observer. Such declarations
* will be resolved when document loading completes.
*/
NS_IMETHOD AddForwardObserverDecl(nsIDOMElement* aListener,
const nsString& aTargetID,
const nsString& aAttribute) = 0;
NS_IMETHOD AddForwardReference(nsForwardReference* aForwardReference) = 0;
NS_IMETHOD ResolveForwardObserverDecls() = 0;
NS_IMETHOD ResolveForwardReferences() = 0;
};
// factory functions
nsresult NS_NewXULDocument(nsIRDFDocument** result);
nsresult NS_NewXULDocument(nsIXULDocument** result);
#endif // nsIRDFDocument_h___
#endif // nsIXULDocument_h___

Просмотреть файл

@ -32,6 +32,7 @@
#include "nsCOMPtr.h"
#include "nsDOMCID.h"
#include "nsDOMEvent.h"
#include "nsForwardReference.h"
#include "nsXULAttributes.h"
#include "nsIXULPopupListener.h"
#include "nsIHTMLContentContainer.h"
@ -54,7 +55,6 @@
#include "nsINameSpaceManager.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIScriptGlobalObject.h"
@ -84,6 +84,7 @@
#include "nsIStyleRule.h"
#include "nsIURL.h"
#include "nsIXULContent.h"
#include "nsIXULDocument.h"
#include "nsXULTreeElement.h"
#include "rdfutil.h"
#include "prlog.h"
@ -334,6 +335,7 @@ public:
NS_IMETHOD SetLazyState(PRInt32 aFlags);
NS_IMETHOD ClearLazyState(PRInt32 aFlags);
NS_IMETHOD GetLazyState(PRInt32 aFlag, PRBool& aValue);
NS_IMETHOD ForceElementToOwnResource(PRBool aForce);
// nsIDOMEventReceiver
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
@ -373,9 +375,6 @@ public:
NS_DECL_IDOMXULELEMENT
// Implementation methods
nsresult GetIdResource(nsIRDFResource** aResult);
nsresult GetRefResource(nsIRDFResource** aResult);
nsresult EnsureContentsGenerated(void) const;
nsresult AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID);
@ -453,6 +452,7 @@ private:
nsIDOMXULElement* mBroadcaster; // [WEAK]
nsCOMPtr<nsIController> mController; // [OWNER]
nsCOMPtr<nsIRDFCompositeDataSource> mDatabase; // [OWNER]
nsCOMPtr<nsIRDFResource> mOwnedResource; // [OWNER]
// An unreferenced bare pointer to an aggregate that can implement
// element-specific APIs.
@ -460,6 +460,29 @@ private:
// The state of our sloth; see nsIXULContent.
PRInt32 mLazyState;
class ObserverForwardReference : public nsForwardReference
{
protected:
nsCOMPtr<nsIDOMElement> mListener;
nsString mTargetID;
nsString mAttributes;
public:
ObserverForwardReference(nsIDOMElement* aListener,
const nsString& aTargetID,
const nsString& aAttributes) :
mListener(aListener),
mTargetID(aTargetID),
mAttributes(aAttributes) {}
virtual ~ObserverForwardReference() {}
virtual Result Resolve();
};
friend class ObserverForwardReference;
};
@ -542,6 +565,44 @@ static EventHandlerMapEntry kEventHandlerMap[] = {
{ nsnull, nsnull, nsnull }
};
////////////////////////////////////////////////////////////////////////
nsForwardReference::Result
RDFElementImpl::ObserverForwardReference::Resolve()
{
nsresult rv;
nsCOMPtr<nsIContent> content = do_QueryInterface(mListener);
if (! content)
return eResolveError;
nsCOMPtr<nsIDocument> doc;
rv = content->GetDocument(*getter_AddRefs(doc));
if (NS_FAILED(rv)) return eResolveError;
nsCOMPtr<nsIDOMXULDocument> xuldoc = do_QueryInterface(doc);
if (! xuldoc)
return eResolveError;
nsCOMPtr<nsIDOMElement> target;
rv = xuldoc->GetElementById(mTargetID, getter_AddRefs(target));
if (NS_FAILED(rv)) return eResolveError;
if (! target)
return eResolveLater;
nsCOMPtr<nsIDOMXULElement> broadcaster = do_QueryInterface(target);
if (! broadcaster)
return eResolveError;
rv = broadcaster->AddBroadcastListener(mAttributes, mListener);
if (NS_FAILED(rv)) return eResolveError;
return eResolveSucceeded;
}
////////////////////////////////////////////////////////////////////////
// RDFElementImpl
@ -1465,6 +1526,24 @@ RDFElementImpl::GetLazyState(PRInt32 aFlag, PRBool& aResult)
return NS_OK;
}
NS_IMETHODIMP
RDFElementImpl::ForceElementToOwnResource(PRBool aForce)
{
nsresult rv;
if (aForce) {
rv = GetResource(getter_AddRefs(mOwnedResource));
if (NS_FAILED(rv)) return rv;
}
else {
// drop reference
mOwnedResource = nsnull;
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsIDOMEventReceiver interface
@ -1691,30 +1770,8 @@ RDFElementImpl::SetDocument(nsIDocument* aDocument, PRBool aDeep)
nsresult rv;
nsCOMPtr<nsIRDFDocument> rdfDoc;
nsCOMPtr<nsIXULDocument> rdfDoc;
if (mDocument) {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
NS_ASSERTION(rdfdoc != nsnull, "ack! not in an RDF document");
if (rdfdoc) {
// Need to do a GetIdResource() here, because changing the document
// may actually change the element's URI.
nsCOMPtr<nsIRDFResource> resource;
GetIdResource(getter_AddRefs(resource));
// Remove this element from the RDF resource-to-element map in
// the old document.
if (resource) {
rv = rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error unmapping resource from element");
}
GetRefResource(getter_AddRefs(resource));
if (resource) {
rv = rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error unmapping resource from element");
}
}
// Release the named reference to the script object so it can
// be garbage collected.
if (mScriptObject) {
@ -1735,28 +1792,6 @@ RDFElementImpl::SetDocument(nsIDocument* aDocument, PRBool aDeep)
mDocument = aDocument; // not refcounted
if (mDocument) {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
NS_ASSERTION(rdfdoc != nsnull, "ack! not in an RDF document");
if (rdfdoc) {
// Need to do a GetIdResource() here, because changing the document
// may actually change the element's URI.
nsCOMPtr<nsIRDFResource> resource;
GetIdResource(getter_AddRefs(resource));
// Add this element to the RDF resource-to-element map in the
// new document.
if (resource) {
rv = rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error mapping resource to element");
}
GetRefResource(getter_AddRefs(resource));
if (resource) {
rv = rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error mapping resource to element");
}
}
// Add a named reference to the script object.
if (mScriptObject) {
nsIScriptContextOwner *owner = mDocument->GetScriptContextOwner();
@ -1859,11 +1894,17 @@ RDFElementImpl::SetParent(nsIContent* aParent)
}
}
else {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
return NS_ERROR_UNEXPECTED;
rdfdoc->AddForwardObserverDecl(listener, elementValue, attributeValue);
ObserverForwardReference* fwdref =
new ObserverForwardReference(listener, elementValue, attributeValue);
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
@ -2268,11 +2309,17 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
}
}
else {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
rdfdoc->AddForwardObserverDecl(this, aValue, "*");
ObserverForwardReference* fwdref =
new ObserverForwardReference(this, aValue, nsAutoString("*"));
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
@ -2347,26 +2394,6 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
NS_IF_RELEASE(popupListener);
}
// Check to see if the REF attribute is being set. If so, we need
// to update the element map. First, remove the old mapping, if
// necessary...
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
nsCOMPtr<nsIRDFResource> resource;
if (aName == kRefAtom) {
GetRefResource(getter_AddRefs(resource));
}
else if (aName == kIdAtom) {
GetIdResource(getter_AddRefs(resource));
}
if (resource) {
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
}
}
// XXX need to check if they're changing an event handler: if so, then we need
// to unhook the old one.
@ -2391,23 +2418,6 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
mAttributes->AppendElement(attr);
}
// Check for REF attribute, part deux. Add the new REF to the map,
// if appropriate.
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
nsCOMPtr<nsIRDFResource> resource;
if (aName == kRefAtom) {
GetRefResource(getter_AddRefs(resource));
}
else if (aName == kIdAtom) {
GetIdResource(getter_AddRefs(resource));
}
if (resource) {
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
}
}
// Check for event handlers and add a script listener if necessary.
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeAtom) {
@ -2529,18 +2539,6 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
else {
rv = NS_CONTENT_ATTR_NO_VALUE;
}
#if 0
if ((aNameSpaceID == kNameSpaceID_None) &&
(attr->mName == kIdAtom))
{
// RDF will treat all document IDs as absolute URIs, so we'll need convert
// a possibly-absolute URI into a relative ID attribute.
NS_ASSERTION(mDocument != nsnull, "not initialized");
if (nsnull != mDocument) {
gXULUtils->MakeElementID(mDocument, attr->mValue, aResult);
}
}
#endif
break;
}
}
@ -3053,15 +3051,25 @@ NS_IMETHODIMP
RDFElementImpl::GetResource(nsIRDFResource** aResource)
{
nsresult rv;
rv = GetRefResource(aResource);
if (NS_FAILED(rv)) return rv;
if (! *aResource) {
rv = GetIdResource(aResource);
nsAutoString id;
rv = GetAttribute(kNameSpaceID_None, kRefAtom, id);
if (NS_FAILED(rv)) return rv;
if (rv != NS_CONTENT_ATTR_HAS_VALUE) {
rv = GetAttribute(kNameSpaceID_None, kIdAtom, id);
if (NS_FAILED(rv)) return rv;
}
}
return NS_OK;
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
rv = gRDFService->GetResource(nsCAutoString(id), aResource);
if (NS_FAILED(rv)) return rv;
}
else {
*aResource = nsnull;
}
return NS_OK;
}
@ -3097,51 +3105,6 @@ RDFElementImpl::SetDatabase(nsIRDFCompositeDataSource* aDatabase)
////////////////////////////////////////////////////////////////////////
// Implementation methods
nsresult
RDFElementImpl::GetIdResource(nsIRDFResource** aResource)
{
if (mAttributes) {
for (PRInt32 i = mAttributes->Count() - 1; i >= 0; --i) {
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
if ((attr->mNameSpaceID == kNameSpaceID_None) &&
(attr->mName == kIdAtom)) {
return gXULUtils->MakeElementResource(mDocument, attr->mValue, aResource);
}
}
}
// No resource associated with this element.
*aResource = nsnull;
return NS_OK;
}
nsresult
RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
{
NS_PRECONDITION(mDocument != nsnull, "not initialized");
if (! mDocument)
return NS_ERROR_NOT_INITIALIZED;
if (mAttributes) {
for (PRInt32 i = mAttributes->Count() - 1; i >= 0; --i) {
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
if (attr->mNameSpaceID != kNameSpaceID_None)
continue;
if (attr->mName != kRefAtom)
continue;
return gXULUtils->MakeElementResource(mDocument, attr->mValue, aResource);
}
}
// If we get here, there was no 'ref' attribute. So return a null resource.
*aResource = nsnull;
return NS_OK;
}
nsresult
RDFElementImpl::EnsureContentsGenerated(void) const
{
@ -3167,7 +3130,7 @@ RDFElementImpl::EnsureContentsGenerated(void) const
// getters if needed.
unconstThis->mLazyState &= ~nsIXULContent::eChildrenMustBeRebuilt;
nsCOMPtr<nsIRDFDocument> rdfDoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfDoc = do_QueryInterface(mDocument);
if (! mDocument)
return NS_OK;

Просмотреть файл

@ -50,7 +50,7 @@
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFDocument.h"
#include "nsIXULDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFObserver.h"
#include "nsIRDFRemoteDataSource.h"
@ -126,7 +126,7 @@ public:
NS_DECL_ISUPPORTS
// nsIRDFContentModelBuilder interface
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
NS_IMETHOD SetDocument(nsIXULDocument* aDocument);
NS_IMETHOD SetDataBase(nsIRDFCompositeDataSource* aDataBase);
NS_IMETHOD GetDataBase(nsIRDFCompositeDataSource** aDataBase);
NS_IMETHOD CreateRootContent(nsIRDFResource* aResource);
@ -135,10 +135,6 @@ public:
NS_IMETHOD OpenContainer(nsIContent* aContainer);
NS_IMETHOD CloseContainer(nsIContent* aContainer);
NS_IMETHOD RebuildContainer(nsIContent* aContainer);
NS_IMETHOD CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIRDFResource* aResource,
nsIContent** aResult);
// nsIRDFObserver interface
NS_IMETHOD OnAssert(nsIRDFResource* aSource,
@ -270,8 +266,16 @@ public:
nsresult
AddDatabasePropertyToHTMLElement(nsIContent* aElement, nsIRDFCompositeDataSource* aDataBase);
nsresult
GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements);
nsresult
CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIContent** aResult);
protected:
nsIRDFDocument* mDocument; // [WEAK]
nsIXULDocument* mDocument; // [WEAK]
// We are an observer of the composite datasource. The cycle is
// broken by out-of-band SetDataBase(nsnull) call when document is
@ -613,7 +617,7 @@ RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
// nsIRDFContentModelBuilder methods
NS_IMETHODIMP
RDFGenericBuilderImpl::SetDocument(nsIRDFDocument* aDocument)
RDFGenericBuilderImpl::SetDocument(nsIXULDocument* aDocument)
{
// note: null now allowed, it indicates document going away
@ -912,74 +916,6 @@ RDFGenericBuilderImpl::RebuildContainer(nsIContent* aElement)
}
NS_IMETHODIMP
RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIRDFResource* aResource,
nsIContent** aResult)
{
nsresult rv;
nsCOMPtr<nsIContent> result;
if (aNameSpaceID == kNameSpaceID_HTML) {
nsCOMPtr<nsIHTMLContent> element;
const PRUnichar *tagName;
aTag->GetUnicode(&tagName);
rv = gHTMLElementFactory->CreateInstanceByTag(tagName, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
result = do_QueryInterface(element);
if (! result)
return NS_ERROR_UNEXPECTED;
}
else {
rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
if (aResource) {
const char *uri;
rv = aResource->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
PRUnichar buf[128];
nsAutoString id(CBufDescriptor(buf, PR_TRUE, sizeof(buf) / sizeof(PRUnichar), 0));
#if 0 // XXX c'mon, this URI is _never_ going to be relative to the document!
rv = gXULUtils->MakeElementID(doc, nsAutoString(uri), id);
if (NS_FAILED(rv)) return rv;
#endif
id = uri;
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
if (NS_FAILED(rv)) return rv;
}
rv = result->SetDocument(doc, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
if (NS_FAILED(rv)) return rv;
if (aResource && aNameSpaceID == kNameSpaceID_HTML) {
// If this is an HTML element, then explicitly add it to the
// map. (XUL elements don't have to do this because their
// SetDocument() call does the magic.) Don't worry: the
// document observer methods are on the lookout to update the
// map for "attribute changed" calls that monkey with the 'id'
// or 'ref' parameters.
rv = mDocument->AddElementForResource(aResource, result);
if (NS_FAILED(rv)) return rv;
}
*aResult = result;
NS_ADDREF(*aResult);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsIRDFObserver interface
@ -1004,9 +940,9 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) return rv;
PRUint32 cnt;
rv = elements->Count(&cnt);
@ -1122,7 +1058,7 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
@ -1246,7 +1182,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
@ -1781,9 +1717,39 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
else if (isResourceElement) {
// It's the "resource" element
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(realKid));
if (NS_FAILED(rv)) return rv;
const char *uri;
rv = aChild->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
nsAutoString id(uri);
rv = realKid->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
if (NS_FAILED(rv)) return rv;
if (! aNotify) {
// XUL document will watch us, and take care of making
// sure that we get added to or removed from the
// element map if aNotify is true. If not, we gotta do
// it ourselves. Yay.
rv = mDocument->AddElementForID(id, realKid);
if (NS_FAILED(rv)) return rv;
}
// XXX Hackery to ensure that mailnews works. Force the
// element to hold a reference to the
// resource. Unfortunately, this'll break for HTML
// elements.
{
nsCOMPtr<nsIXULContent> xulele = do_QueryInterface(realKid);
if (xulele) {
xulele->ForceElementToOwnResource(PR_TRUE);
}
}
if (IsContainer(tmplKid, aChild)) {
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
if (NS_FAILED(rv)) return rv;
@ -1823,7 +1789,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
else {
// It's just a generic element. Create it!
rv = CreateElement(nameSpaceID, tag, nsnull, getter_AddRefs(realKid));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(realKid));
if (NS_FAILED(rv)) return rv;
}
@ -2146,7 +2112,7 @@ RDFGenericBuilderImpl::RemoveWidgetItem(nsIContent* aElement,
rv = NS_NewISupportsArray(getter_AddRefs(elements));
if (NS_FAILED(rv)) return rv;
rv = mDocument->GetElementsForResource(aValue, elements);
rv = GetElementsForResource(aValue, elements);
if (NS_FAILED(rv)) return rv;
PRUint32 cnt;
@ -2362,7 +2328,7 @@ RDFGenericBuilderImpl::EnsureElementHasGenericChild(nsIContent* parent,
// we need to construct a new child element.
nsCOMPtr<nsIContent> element;
rv = CreateElement(nameSpaceID, tag, nsnull, getter_AddRefs(element));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
// XXX Note that the notification ensures we won't batch insertions! This could be bad! - Dave
@ -2918,3 +2884,59 @@ RDFGenericBuilderImpl::AddDatabasePropertyToHTMLElement(nsIContent* aElement, ns
return NS_OK;
}
nsresult
RDFGenericBuilderImpl::GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements)
{
nsresult rv;
const char *uri;
rv = aResource->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
rv = mDocument->GetElementsForID(nsAutoString(uri), aElements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsresult
RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIContent** aResult)
{
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
if (! doc)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
nsCOMPtr<nsIContent> result;
if (aNameSpaceID == kNameSpaceID_HTML) {
nsCOMPtr<nsIHTMLContent> element;
const PRUnichar *tagName;
aTag->GetUnicode(&tagName);
rv = gHTMLElementFactory->CreateInstanceByTag(tagName, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
result = do_QueryInterface(element);
if (! result)
return NS_ERROR_UNEXPECTED;
}
else {
rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
}
rv = result->SetDocument(doc, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
if (NS_FAILED(rv)) return rv;
*aResult = result;
NS_ADDREF(*aResult);
return NS_OK;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -32,6 +32,7 @@
#include "nsCOMPtr.h"
#include "nsDOMCID.h"
#include "nsDOMEvent.h"
#include "nsForwardReference.h"
#include "nsXULAttributes.h"
#include "nsIXULPopupListener.h"
#include "nsIHTMLContentContainer.h"
@ -54,7 +55,6 @@
#include "nsINameSpaceManager.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIScriptGlobalObject.h"
@ -84,6 +84,7 @@
#include "nsIStyleRule.h"
#include "nsIURL.h"
#include "nsIXULContent.h"
#include "nsIXULDocument.h"
#include "nsXULTreeElement.h"
#include "rdfutil.h"
#include "prlog.h"
@ -334,6 +335,7 @@ public:
NS_IMETHOD SetLazyState(PRInt32 aFlags);
NS_IMETHOD ClearLazyState(PRInt32 aFlags);
NS_IMETHOD GetLazyState(PRInt32 aFlag, PRBool& aValue);
NS_IMETHOD ForceElementToOwnResource(PRBool aForce);
// nsIDOMEventReceiver
NS_IMETHOD AddEventListenerByIID(nsIDOMEventListener *aListener, const nsIID& aIID);
@ -373,9 +375,6 @@ public:
NS_DECL_IDOMXULELEMENT
// Implementation methods
nsresult GetIdResource(nsIRDFResource** aResult);
nsresult GetRefResource(nsIRDFResource** aResult);
nsresult EnsureContentsGenerated(void) const;
nsresult AddScriptEventListener(nsIAtom* aName, const nsString& aValue, REFNSIID aIID);
@ -453,6 +452,7 @@ private:
nsIDOMXULElement* mBroadcaster; // [WEAK]
nsCOMPtr<nsIController> mController; // [OWNER]
nsCOMPtr<nsIRDFCompositeDataSource> mDatabase; // [OWNER]
nsCOMPtr<nsIRDFResource> mOwnedResource; // [OWNER]
// An unreferenced bare pointer to an aggregate that can implement
// element-specific APIs.
@ -460,6 +460,29 @@ private:
// The state of our sloth; see nsIXULContent.
PRInt32 mLazyState;
class ObserverForwardReference : public nsForwardReference
{
protected:
nsCOMPtr<nsIDOMElement> mListener;
nsString mTargetID;
nsString mAttributes;
public:
ObserverForwardReference(nsIDOMElement* aListener,
const nsString& aTargetID,
const nsString& aAttributes) :
mListener(aListener),
mTargetID(aTargetID),
mAttributes(aAttributes) {}
virtual ~ObserverForwardReference() {}
virtual Result Resolve();
};
friend class ObserverForwardReference;
};
@ -542,6 +565,44 @@ static EventHandlerMapEntry kEventHandlerMap[] = {
{ nsnull, nsnull, nsnull }
};
////////////////////////////////////////////////////////////////////////
nsForwardReference::Result
RDFElementImpl::ObserverForwardReference::Resolve()
{
nsresult rv;
nsCOMPtr<nsIContent> content = do_QueryInterface(mListener);
if (! content)
return eResolveError;
nsCOMPtr<nsIDocument> doc;
rv = content->GetDocument(*getter_AddRefs(doc));
if (NS_FAILED(rv)) return eResolveError;
nsCOMPtr<nsIDOMXULDocument> xuldoc = do_QueryInterface(doc);
if (! xuldoc)
return eResolveError;
nsCOMPtr<nsIDOMElement> target;
rv = xuldoc->GetElementById(mTargetID, getter_AddRefs(target));
if (NS_FAILED(rv)) return eResolveError;
if (! target)
return eResolveLater;
nsCOMPtr<nsIDOMXULElement> broadcaster = do_QueryInterface(target);
if (! broadcaster)
return eResolveError;
rv = broadcaster->AddBroadcastListener(mAttributes, mListener);
if (NS_FAILED(rv)) return eResolveError;
return eResolveSucceeded;
}
////////////////////////////////////////////////////////////////////////
// RDFElementImpl
@ -1465,6 +1526,24 @@ RDFElementImpl::GetLazyState(PRInt32 aFlag, PRBool& aResult)
return NS_OK;
}
NS_IMETHODIMP
RDFElementImpl::ForceElementToOwnResource(PRBool aForce)
{
nsresult rv;
if (aForce) {
rv = GetResource(getter_AddRefs(mOwnedResource));
if (NS_FAILED(rv)) return rv;
}
else {
// drop reference
mOwnedResource = nsnull;
}
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsIDOMEventReceiver interface
@ -1691,30 +1770,8 @@ RDFElementImpl::SetDocument(nsIDocument* aDocument, PRBool aDeep)
nsresult rv;
nsCOMPtr<nsIRDFDocument> rdfDoc;
nsCOMPtr<nsIXULDocument> rdfDoc;
if (mDocument) {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
NS_ASSERTION(rdfdoc != nsnull, "ack! not in an RDF document");
if (rdfdoc) {
// Need to do a GetIdResource() here, because changing the document
// may actually change the element's URI.
nsCOMPtr<nsIRDFResource> resource;
GetIdResource(getter_AddRefs(resource));
// Remove this element from the RDF resource-to-element map in
// the old document.
if (resource) {
rv = rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error unmapping resource from element");
}
GetRefResource(getter_AddRefs(resource));
if (resource) {
rv = rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error unmapping resource from element");
}
}
// Release the named reference to the script object so it can
// be garbage collected.
if (mScriptObject) {
@ -1735,28 +1792,6 @@ RDFElementImpl::SetDocument(nsIDocument* aDocument, PRBool aDeep)
mDocument = aDocument; // not refcounted
if (mDocument) {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
NS_ASSERTION(rdfdoc != nsnull, "ack! not in an RDF document");
if (rdfdoc) {
// Need to do a GetIdResource() here, because changing the document
// may actually change the element's URI.
nsCOMPtr<nsIRDFResource> resource;
GetIdResource(getter_AddRefs(resource));
// Add this element to the RDF resource-to-element map in the
// new document.
if (resource) {
rv = rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error mapping resource to element");
}
GetRefResource(getter_AddRefs(resource));
if (resource) {
rv = rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
NS_ASSERTION(NS_SUCCEEDED(rv), "error mapping resource to element");
}
}
// Add a named reference to the script object.
if (mScriptObject) {
nsIScriptContextOwner *owner = mDocument->GetScriptContextOwner();
@ -1859,11 +1894,17 @@ RDFElementImpl::SetParent(nsIContent* aParent)
}
}
else {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
return NS_ERROR_UNEXPECTED;
rdfdoc->AddForwardObserverDecl(listener, elementValue, attributeValue);
ObserverForwardReference* fwdref =
new ObserverForwardReference(listener, elementValue, attributeValue);
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
@ -2268,11 +2309,17 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
}
}
else {
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfdoc = do_QueryInterface(mDocument);
if (! rdfdoc)
return NS_ERROR_UNEXPECTED;
rdfdoc->AddForwardObserverDecl(this, aValue, "*");
ObserverForwardReference* fwdref =
new ObserverForwardReference(this, aValue, nsAutoString("*"));
if (! fwdref)
return NS_ERROR_OUT_OF_MEMORY;
rdfdoc->AddForwardReference(fwdref);
}
}
@ -2347,26 +2394,6 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
NS_IF_RELEASE(popupListener);
}
// Check to see if the REF attribute is being set. If so, we need
// to update the element map. First, remove the old mapping, if
// necessary...
nsCOMPtr<nsIRDFDocument> rdfdoc = do_QueryInterface(mDocument);
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
nsCOMPtr<nsIRDFResource> resource;
if (aName == kRefAtom) {
GetRefResource(getter_AddRefs(resource));
}
else if (aName == kIdAtom) {
GetIdResource(getter_AddRefs(resource));
}
if (resource) {
rdfdoc->RemoveElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
}
}
// XXX need to check if they're changing an event handler: if so, then we need
// to unhook the old one.
@ -2391,23 +2418,6 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID,
mAttributes->AppendElement(attr);
}
// Check for REF attribute, part deux. Add the new REF to the map,
// if appropriate.
if (rdfdoc && (aNameSpaceID == kNameSpaceID_None)) {
nsCOMPtr<nsIRDFResource> resource;
if (aName == kRefAtom) {
GetRefResource(getter_AddRefs(resource));
}
else if (aName == kIdAtom) {
GetIdResource(getter_AddRefs(resource));
}
if (resource) {
rdfdoc->AddElementForResource(resource, NS_STATIC_CAST(nsIStyledContent*, this));
}
}
// Check for event handlers and add a script listener if necessary.
EventHandlerMapEntry* entry = kEventHandlerMap;
while (entry->mAttributeAtom) {
@ -2529,18 +2539,6 @@ RDFElementImpl::GetAttribute(PRInt32 aNameSpaceID,
else {
rv = NS_CONTENT_ATTR_NO_VALUE;
}
#if 0
if ((aNameSpaceID == kNameSpaceID_None) &&
(attr->mName == kIdAtom))
{
// RDF will treat all document IDs as absolute URIs, so we'll need convert
// a possibly-absolute URI into a relative ID attribute.
NS_ASSERTION(mDocument != nsnull, "not initialized");
if (nsnull != mDocument) {
gXULUtils->MakeElementID(mDocument, attr->mValue, aResult);
}
}
#endif
break;
}
}
@ -3053,15 +3051,25 @@ NS_IMETHODIMP
RDFElementImpl::GetResource(nsIRDFResource** aResource)
{
nsresult rv;
rv = GetRefResource(aResource);
if (NS_FAILED(rv)) return rv;
if (! *aResource) {
rv = GetIdResource(aResource);
nsAutoString id;
rv = GetAttribute(kNameSpaceID_None, kRefAtom, id);
if (NS_FAILED(rv)) return rv;
if (rv != NS_CONTENT_ATTR_HAS_VALUE) {
rv = GetAttribute(kNameSpaceID_None, kIdAtom, id);
if (NS_FAILED(rv)) return rv;
}
}
return NS_OK;
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
rv = gRDFService->GetResource(nsCAutoString(id), aResource);
if (NS_FAILED(rv)) return rv;
}
else {
*aResource = nsnull;
}
return NS_OK;
}
@ -3097,51 +3105,6 @@ RDFElementImpl::SetDatabase(nsIRDFCompositeDataSource* aDatabase)
////////////////////////////////////////////////////////////////////////
// Implementation methods
nsresult
RDFElementImpl::GetIdResource(nsIRDFResource** aResource)
{
if (mAttributes) {
for (PRInt32 i = mAttributes->Count() - 1; i >= 0; --i) {
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
if ((attr->mNameSpaceID == kNameSpaceID_None) &&
(attr->mName == kIdAtom)) {
return gXULUtils->MakeElementResource(mDocument, attr->mValue, aResource);
}
}
}
// No resource associated with this element.
*aResource = nsnull;
return NS_OK;
}
nsresult
RDFElementImpl::GetRefResource(nsIRDFResource** aResource)
{
NS_PRECONDITION(mDocument != nsnull, "not initialized");
if (! mDocument)
return NS_ERROR_NOT_INITIALIZED;
if (mAttributes) {
for (PRInt32 i = mAttributes->Count() - 1; i >= 0; --i) {
const nsXULAttribute* attr = (const nsXULAttribute*) mAttributes->ElementAt(i);
if (attr->mNameSpaceID != kNameSpaceID_None)
continue;
if (attr->mName != kRefAtom)
continue;
return gXULUtils->MakeElementResource(mDocument, attr->mValue, aResource);
}
}
// If we get here, there was no 'ref' attribute. So return a null resource.
*aResource = nsnull;
return NS_OK;
}
nsresult
RDFElementImpl::EnsureContentsGenerated(void) const
{
@ -3167,7 +3130,7 @@ RDFElementImpl::EnsureContentsGenerated(void) const
// getters if needed.
unconstThis->mLazyState &= ~nsIXULContent::eChildrenMustBeRebuilt;
nsCOMPtr<nsIRDFDocument> rdfDoc = do_QueryInterface(mDocument);
nsCOMPtr<nsIXULDocument> rdfDoc = do_QueryInterface(mDocument);
if (! mDocument)
return NS_OK;

Просмотреть файл

@ -30,7 +30,6 @@
#include "nsINameSpaceManager.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFObserver.h"
#include "nsIRDFService.h"

Просмотреть файл

@ -50,7 +50,7 @@
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFContainerUtils.h"
#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFDocument.h"
#include "nsIXULDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFObserver.h"
#include "nsIRDFRemoteDataSource.h"
@ -126,7 +126,7 @@ public:
NS_DECL_ISUPPORTS
// nsIRDFContentModelBuilder interface
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
NS_IMETHOD SetDocument(nsIXULDocument* aDocument);
NS_IMETHOD SetDataBase(nsIRDFCompositeDataSource* aDataBase);
NS_IMETHOD GetDataBase(nsIRDFCompositeDataSource** aDataBase);
NS_IMETHOD CreateRootContent(nsIRDFResource* aResource);
@ -135,10 +135,6 @@ public:
NS_IMETHOD OpenContainer(nsIContent* aContainer);
NS_IMETHOD CloseContainer(nsIContent* aContainer);
NS_IMETHOD RebuildContainer(nsIContent* aContainer);
NS_IMETHOD CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIRDFResource* aResource,
nsIContent** aResult);
// nsIRDFObserver interface
NS_IMETHOD OnAssert(nsIRDFResource* aSource,
@ -270,8 +266,16 @@ public:
nsresult
AddDatabasePropertyToHTMLElement(nsIContent* aElement, nsIRDFCompositeDataSource* aDataBase);
nsresult
GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements);
nsresult
CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIContent** aResult);
protected:
nsIRDFDocument* mDocument; // [WEAK]
nsIXULDocument* mDocument; // [WEAK]
// We are an observer of the composite datasource. The cycle is
// broken by out-of-band SetDataBase(nsnull) call when document is
@ -613,7 +617,7 @@ RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
// nsIRDFContentModelBuilder methods
NS_IMETHODIMP
RDFGenericBuilderImpl::SetDocument(nsIRDFDocument* aDocument)
RDFGenericBuilderImpl::SetDocument(nsIXULDocument* aDocument)
{
// note: null now allowed, it indicates document going away
@ -912,74 +916,6 @@ RDFGenericBuilderImpl::RebuildContainer(nsIContent* aElement)
}
NS_IMETHODIMP
RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIRDFResource* aResource,
nsIContent** aResult)
{
nsresult rv;
nsCOMPtr<nsIContent> result;
if (aNameSpaceID == kNameSpaceID_HTML) {
nsCOMPtr<nsIHTMLContent> element;
const PRUnichar *tagName;
aTag->GetUnicode(&tagName);
rv = gHTMLElementFactory->CreateInstanceByTag(tagName, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
result = do_QueryInterface(element);
if (! result)
return NS_ERROR_UNEXPECTED;
}
else {
rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
if (aResource) {
const char *uri;
rv = aResource->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
PRUnichar buf[128];
nsAutoString id(CBufDescriptor(buf, PR_TRUE, sizeof(buf) / sizeof(PRUnichar), 0));
#if 0 // XXX c'mon, this URI is _never_ going to be relative to the document!
rv = gXULUtils->MakeElementID(doc, nsAutoString(uri), id);
if (NS_FAILED(rv)) return rv;
#endif
id = uri;
rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
if (NS_FAILED(rv)) return rv;
}
rv = result->SetDocument(doc, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
if (NS_FAILED(rv)) return rv;
if (aResource && aNameSpaceID == kNameSpaceID_HTML) {
// If this is an HTML element, then explicitly add it to the
// map. (XUL elements don't have to do this because their
// SetDocument() call does the magic.) Don't worry: the
// document observer methods are on the lookout to update the
// map for "attribute changed" calls that monkey with the 'id'
// or 'ref' parameters.
rv = mDocument->AddElementForResource(aResource, result);
if (NS_FAILED(rv)) return rv;
}
*aResult = result;
NS_ADDREF(*aResult);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
// nsIRDFObserver interface
@ -1004,9 +940,9 @@ RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) return rv;
PRUint32 cnt;
rv = elements->Count(&cnt);
@ -1122,7 +1058,7 @@ RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
@ -1246,7 +1182,7 @@ RDFGenericBuilderImpl::OnChange(nsIRDFResource* aSource,
// Find all the elements in the content model that correspond to
// aSource: for each, we'll try to build XUL children if
// appropriate.
rv = mDocument->GetElementsForResource(aSource, elements);
rv = GetElementsForResource(aSource, elements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
@ -1781,9 +1717,39 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
else if (isResourceElement) {
// It's the "resource" element
rv = CreateElement(nameSpaceID, tag, aChild, getter_AddRefs(realKid));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(realKid));
if (NS_FAILED(rv)) return rv;
const char *uri;
rv = aChild->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
nsAutoString id(uri);
rv = realKid->SetAttribute(kNameSpaceID_None, kIdAtom, id, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set id attribute");
if (NS_FAILED(rv)) return rv;
if (! aNotify) {
// XUL document will watch us, and take care of making
// sure that we get added to or removed from the
// element map if aNotify is true. If not, we gotta do
// it ourselves. Yay.
rv = mDocument->AddElementForID(id, realKid);
if (NS_FAILED(rv)) return rv;
}
// XXX Hackery to ensure that mailnews works. Force the
// element to hold a reference to the
// resource. Unfortunately, this'll break for HTML
// elements.
{
nsCOMPtr<nsIXULContent> xulele = do_QueryInterface(realKid);
if (xulele) {
xulele->ForceElementToOwnResource(PR_TRUE);
}
}
if (IsContainer(tmplKid, aChild)) {
rv = realKid->SetAttribute(kNameSpaceID_None, kContainerAtom, nsAutoString("true"), PR_FALSE);
if (NS_FAILED(rv)) return rv;
@ -1823,7 +1789,7 @@ RDFGenericBuilderImpl::BuildContentFromTemplate(nsIContent *aTemplateNode,
}
else {
// It's just a generic element. Create it!
rv = CreateElement(nameSpaceID, tag, nsnull, getter_AddRefs(realKid));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(realKid));
if (NS_FAILED(rv)) return rv;
}
@ -2146,7 +2112,7 @@ RDFGenericBuilderImpl::RemoveWidgetItem(nsIContent* aElement,
rv = NS_NewISupportsArray(getter_AddRefs(elements));
if (NS_FAILED(rv)) return rv;
rv = mDocument->GetElementsForResource(aValue, elements);
rv = GetElementsForResource(aValue, elements);
if (NS_FAILED(rv)) return rv;
PRUint32 cnt;
@ -2362,7 +2328,7 @@ RDFGenericBuilderImpl::EnsureElementHasGenericChild(nsIContent* parent,
// we need to construct a new child element.
nsCOMPtr<nsIContent> element;
rv = CreateElement(nameSpaceID, tag, nsnull, getter_AddRefs(element));
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
// XXX Note that the notification ensures we won't batch insertions! This could be bad! - Dave
@ -2918,3 +2884,59 @@ RDFGenericBuilderImpl::AddDatabasePropertyToHTMLElement(nsIContent* aElement, ns
return NS_OK;
}
nsresult
RDFGenericBuilderImpl::GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements)
{
nsresult rv;
const char *uri;
rv = aResource->GetValueConst(&uri);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource URI");
if (NS_FAILED(rv)) return rv;
rv = mDocument->GetElementsForID(nsAutoString(uri), aElements);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsresult
RDFGenericBuilderImpl::CreateElement(PRInt32 aNameSpaceID,
nsIAtom* aTag,
nsIContent** aResult)
{
nsCOMPtr<nsIDocument> doc = do_QueryInterface(mDocument);
if (! doc)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
nsCOMPtr<nsIContent> result;
if (aNameSpaceID == kNameSpaceID_HTML) {
nsCOMPtr<nsIHTMLContent> element;
const PRUnichar *tagName;
aTag->GetUnicode(&tagName);
rv = gHTMLElementFactory->CreateInstanceByTag(tagName, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
result = do_QueryInterface(element);
if (! result)
return NS_ERROR_UNEXPECTED;
}
else {
rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(result));
if (NS_FAILED(rv)) return rv;
}
rv = result->SetDocument(doc, PR_FALSE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document");
if (NS_FAILED(rv)) return rv;
*aResult = result;
NS_ADDREF(*aResult);
return NS_OK;
}

Просмотреть файл

@ -1,5 +1,4 @@
nsILocalStore.h
nsIRDFFileSystem.h
nsIRDFFTP.h
nsIXULContentSink.h

Просмотреть файл

@ -28,7 +28,6 @@ EXPORTS = \
nsILocalStore.h \
nsIRDFFileSystem.h \
nsIRDFFTP.h \
nsIXULContentSink.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

Просмотреть файл

@ -24,7 +24,6 @@ EXPORTS = \
nsILocalStore.h \
nsIRDFFileSystem.h \
nsIRDFFTP.h \
nsIXULContentSink.h \
$(NULL)
include <$(DEPTH)/config/rules.mak>

Просмотреть файл

@ -31,7 +31,6 @@ CPPSRCS = \
nsLocalStore.cpp \
nsFileSystemDataSource.cpp \
nsFTPDataSource.cpp \
nsXULContentSink.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.
@ -44,7 +43,3 @@ include $(topsrcdir)/config/rules.mk
# a first-class XPCOM interface.
INCLUDES += -I$(srcdir)/../../base/src
# XXX This is a dependency on nsRDFContentUtils.h. This'll go away once
# XUL gets to live in it's own DLL like a big boy.
INCLUDES += -I$(srcdir)/../../content/src

Просмотреть файл

@ -25,7 +25,6 @@ CPP_OBJS=\
.\$(OBJDIR)\nsFileSystemDataSource.obj \
.\$(OBJDIR)\nsFTPDataSource.obj \
.\$(OBJDIR)\nsLocalStore.obj \
.\$(OBJDIR)\nsXULContentSink.obj \
$(NULL)
# XXX Note the dependency on $(DEPTH)\rdf\base\src: we use rdfutil.h over
@ -33,7 +32,6 @@ CPP_OBJS=\
# "real live" XPCOM interface.
LINCS= -I$(DEPTH)\rdf\base\src \
-I$(DEPTH)\rdf\content\src \
$(NULL)
include <$(DEPTH)\config\rules.mak>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Двоичные данные
rdf/macbuild/rdf.mcp

Двоичный файл не отображается.

Просмотреть файл

@ -40,7 +40,6 @@ NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
#include "nsIGenericFactory.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFRemoteDataSource.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIRDFXMLSource.h"