From 77a02a8fff3d0f93640ceffeb476601b25fef600 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Mon, 6 Dec 1999 23:05:31 +0000 Subject: [PATCH] Bug 16709. Set 'content ID' fields on elements as they are constructed from XUL. --- content/xul/content/src/nsXULElement.cpp | 7 ++++--- content/xul/content/src/nsXULElement.h | 1 + content/xul/document/src/nsXULDocument.cpp | 11 ++++++++--- content/xul/document/src/nsXULDocument.h | 1 + rdf/content/src/nsXULDocument.cpp | 11 ++++++++--- rdf/content/src/nsXULDocument.h | 1 + rdf/content/src/nsXULElement.cpp | 7 ++++--- rdf/content/src/nsXULElement.h | 1 + 8 files changed, 28 insertions(+), 12 deletions(-) diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 864507347ac7..5f82f2aa664f 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -2717,14 +2717,15 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext, NS_IMETHODIMP nsXULElement::GetContentID(PRUint32* aID) { - *aID = 0; - return NS_ERROR_NOT_IMPLEMENTED; + *aID = mContentId; + return NS_OK; } NS_IMETHODIMP nsXULElement::SetContentID(PRUint32 aID) { - return NS_ERROR_NOT_IMPLEMENTED; + mContentId = aID; + return NS_OK; } NS_IMETHODIMP diff --git a/content/xul/content/src/nsXULElement.h b/content/xul/content/src/nsXULElement.h index bc229b04f681..5b7e6dc2b399 100644 --- a/content/xul/content/src/nsXULElement.h +++ b/content/xul/content/src/nsXULElement.h @@ -519,6 +519,7 @@ protected: nsCOMPtr mChildren; // [OWNER] nsCOMPtr mListenerManager; // [OWNER] void* mScriptObject; // [OWNER] + PRInt32 mContentId; // The state of our sloth for lazy content model construction via // RDF; see nsIXULContent and nsRDFGenericBuilder. diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 56121d61b9ae..fb9f140a8267 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -55,6 +55,7 @@ #include "nsIBrowserWindow.h" #include "nsIChromeRegistry.h" #include "nsIComponentManager.h" +#include "nsIContentSink.h" // for NS_CONTENT_ID_COUNTER_BASE #include "nsIContentViewer.h" #include "nsICSSStyleSheet.h" #include "nsIDOMEvent.h" @@ -203,7 +204,6 @@ nsIXULPrototypeCache* nsXULDocument::gXULCache; PRLogModuleInfo* nsXULDocument::gXULLog; - //---------------------------------------------------------------------- // // PlaceholderChannel @@ -310,6 +310,7 @@ nsXULDocument::nsXULDocument(void) mDisplaySelection(PR_FALSE), mIsPopup(PR_FALSE), mResolutionPhase(nsForwardReference::eStart), + mNextContentID(NS_CONTENT_ID_COUNTER_BASE), mState(eState_Master), mCurrentScriptProto(nsnull) { @@ -3886,8 +3887,8 @@ nsXULDocument::RebuildWidgetItem(nsIContent* aElement) nsresult nsXULDocument::CreateElement(PRInt32 aNameSpaceID, - nsIAtom* aTag, - nsIContent** aResult) + nsIAtom* aTag, + nsIContent** aResult) { nsresult rv; nsCOMPtr result; @@ -3913,6 +3914,8 @@ nsXULDocument::CreateElement(PRInt32 aNameSpaceID, NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document"); if (NS_FAILED(rv)) return rv; + result->SetContentID(mNextContentID++); + *aResult = result; NS_ADDREF(*aResult); return NS_OK; @@ -4941,6 +4944,8 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe } } + result->SetContentID(mNextContentID++); + *aResult = result; NS_ADDREF(*aResult); return NS_OK; diff --git a/content/xul/document/src/nsXULDocument.h b/content/xul/document/src/nsXULDocument.h index 313c478f0fd7..1bfb50ddca96 100644 --- a/content/xul/document/src/nsXULDocument.h +++ b/content/xul/document/src/nsXULDocument.h @@ -525,6 +525,7 @@ protected: nsVoidArray mForwardReferences; nsForwardReference::Phase mResolutionPhase; + PRInt32 mNextContentID; // The following are pointers into the content model which provide access to // the objects triggering either a popup or a tooltip. These are marked as diff --git a/rdf/content/src/nsXULDocument.cpp b/rdf/content/src/nsXULDocument.cpp index 56121d61b9ae..fb9f140a8267 100644 --- a/rdf/content/src/nsXULDocument.cpp +++ b/rdf/content/src/nsXULDocument.cpp @@ -55,6 +55,7 @@ #include "nsIBrowserWindow.h" #include "nsIChromeRegistry.h" #include "nsIComponentManager.h" +#include "nsIContentSink.h" // for NS_CONTENT_ID_COUNTER_BASE #include "nsIContentViewer.h" #include "nsICSSStyleSheet.h" #include "nsIDOMEvent.h" @@ -203,7 +204,6 @@ nsIXULPrototypeCache* nsXULDocument::gXULCache; PRLogModuleInfo* nsXULDocument::gXULLog; - //---------------------------------------------------------------------- // // PlaceholderChannel @@ -310,6 +310,7 @@ nsXULDocument::nsXULDocument(void) mDisplaySelection(PR_FALSE), mIsPopup(PR_FALSE), mResolutionPhase(nsForwardReference::eStart), + mNextContentID(NS_CONTENT_ID_COUNTER_BASE), mState(eState_Master), mCurrentScriptProto(nsnull) { @@ -3886,8 +3887,8 @@ nsXULDocument::RebuildWidgetItem(nsIContent* aElement) nsresult nsXULDocument::CreateElement(PRInt32 aNameSpaceID, - nsIAtom* aTag, - nsIContent** aResult) + nsIAtom* aTag, + nsIContent** aResult) { nsresult rv; nsCOMPtr result; @@ -3913,6 +3914,8 @@ nsXULDocument::CreateElement(PRInt32 aNameSpaceID, NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's document"); if (NS_FAILED(rv)) return rv; + result->SetContentID(mNextContentID++); + *aResult = result; NS_ADDREF(*aResult); return NS_OK; @@ -4941,6 +4944,8 @@ nsXULDocument::CreateElement(nsXULPrototypeElement* aPrototype, nsIContent** aRe } } + result->SetContentID(mNextContentID++); + *aResult = result; NS_ADDREF(*aResult); return NS_OK; diff --git a/rdf/content/src/nsXULDocument.h b/rdf/content/src/nsXULDocument.h index 313c478f0fd7..1bfb50ddca96 100644 --- a/rdf/content/src/nsXULDocument.h +++ b/rdf/content/src/nsXULDocument.h @@ -525,6 +525,7 @@ protected: nsVoidArray mForwardReferences; nsForwardReference::Phase mResolutionPhase; + PRInt32 mNextContentID; // The following are pointers into the content model which provide access to // the objects triggering either a popup or a tooltip. These are marked as diff --git a/rdf/content/src/nsXULElement.cpp b/rdf/content/src/nsXULElement.cpp index 864507347ac7..5f82f2aa664f 100644 --- a/rdf/content/src/nsXULElement.cpp +++ b/rdf/content/src/nsXULElement.cpp @@ -2717,14 +2717,15 @@ nsXULElement::HandleDOMEvent(nsIPresContext* aPresContext, NS_IMETHODIMP nsXULElement::GetContentID(PRUint32* aID) { - *aID = 0; - return NS_ERROR_NOT_IMPLEMENTED; + *aID = mContentId; + return NS_OK; } NS_IMETHODIMP nsXULElement::SetContentID(PRUint32 aID) { - return NS_ERROR_NOT_IMPLEMENTED; + mContentId = aID; + return NS_OK; } NS_IMETHODIMP diff --git a/rdf/content/src/nsXULElement.h b/rdf/content/src/nsXULElement.h index bc229b04f681..5b7e6dc2b399 100644 --- a/rdf/content/src/nsXULElement.h +++ b/rdf/content/src/nsXULElement.h @@ -519,6 +519,7 @@ protected: nsCOMPtr mChildren; // [OWNER] nsCOMPtr mListenerManager; // [OWNER] void* mScriptObject; // [OWNER] + PRInt32 mContentId; // The state of our sloth for lazy content model construction via // RDF; see nsIXULContent and nsRDFGenericBuilder.