diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 864507347ac..5f82f2aa664 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 bc229b04f68..5b7e6dc2b39 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 56121d61b9a..fb9f140a826 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 313c478f0fd..1bfb50ddca9 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 56121d61b9a..fb9f140a826 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 313c478f0fd..1bfb50ddca9 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 864507347ac..5f82f2aa664 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 bc229b04f68..5b7e6dc2b39 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.