зеркало из https://github.com/mozilla/pjs.git
r=pollmann. Bug 30916. Content IDs are created for HTML elements created in the HTML content sink, XML content sink and dynamically via JS. The content ID counter is maintained by the document.
This commit is contained in:
Родитель
48e2c3ad17
Коммит
e90cbb686f
|
@ -80,6 +80,12 @@ public:
|
|||
};
|
||||
#endif
|
||||
|
||||
// The base value for the content ID counter.
|
||||
// This counter is used by the document to
|
||||
// assign a monotonically increasing ID to each content
|
||||
// object it creates
|
||||
#define NS_CONTENT_ID_COUNTER_BASE 10000
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Document interface
|
||||
|
@ -311,9 +317,9 @@ public:
|
|||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus) = 0;
|
||||
|
||||
|
||||
NS_IMETHOD FlushPendingNotifications() = 0;
|
||||
|
||||
NS_IMETHOD GetAndIncrementContentID(PRInt32* aID) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -591,6 +591,7 @@ nsDocument::nsDocument()
|
|||
mModCount = 0;
|
||||
mFileSpec = nsnull;
|
||||
mPrincipal = nsnull;
|
||||
mNextContentID = NS_CONTENT_ID_COUNTER_BASE;
|
||||
Init();/* XXX */
|
||||
}
|
||||
|
||||
|
@ -3056,6 +3057,14 @@ nsDocument::FlushPendingNotifications()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetAndIncrementContentID(PRInt32* aID)
|
||||
{
|
||||
*aID = mNextContentID++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetModCount(PRInt32 *outModCount)
|
||||
{
|
||||
|
|
|
@ -318,6 +318,7 @@ public:
|
|||
virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
|
||||
NS_IMETHOD FlushPendingNotifications();
|
||||
NS_IMETHOD GetAndIncrementContentID(PRInt32* aID);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -489,7 +490,10 @@ protected:
|
|||
nsVoidArray *mEpilog;
|
||||
nsDocumentChildNodes* mChildNodes;
|
||||
nsIWordBreaker* mWordBreaker;
|
||||
|
||||
// A content ID counter used to give a monotonically increasing ID to the content
|
||||
// objects in the document's content model
|
||||
PRInt32 mNextContentID;
|
||||
|
||||
// disk file members
|
||||
nsFileSpec* mFileSpec;
|
||||
PRInt32 mModCount;
|
||||
|
|
|
@ -299,6 +299,13 @@ nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent,
|
|||
result = mAttributes->Clone(&(aDst->mAttributes));
|
||||
}
|
||||
|
||||
PRInt32 id;
|
||||
if (mDocument) {
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
}
|
||||
if (aDst && aDst->mContent) {
|
||||
aDst->mContent->SetContentID(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,6 @@ public:
|
|||
nsString mPreferredStyle;
|
||||
PRInt32 mStyleSheetCount;
|
||||
nsICSSLoader* mCSSLoader;
|
||||
PRUint32 mContentIDCounter;
|
||||
PRInt32 mInsideNoXXXTag;
|
||||
PRInt32 mInMonolithicContainer;
|
||||
|
||||
|
@ -970,6 +969,10 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
|||
}
|
||||
rv = MakeContentObject(aNodeType, atom, aForm, aWebShell,
|
||||
aResult, &content);
|
||||
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
(*aResult)->SetContentID(id);
|
||||
|
||||
NS_RELEASE(atom);
|
||||
}
|
||||
|
@ -1261,7 +1264,6 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
|
|||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
content->SetContentID(mSink->mContentIDCounter++);
|
||||
|
||||
nsresult srv;
|
||||
nsCOMPtr<nsISelectElement> select = do_QueryInterface(content, &srv);
|
||||
|
@ -1617,8 +1619,7 @@ SinkContext::AddLeaf(const nsIParserNode& aNode)
|
|||
&content);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
content->SetContentID(mSink->mContentIDCounter++);
|
||||
}
|
||||
|
||||
// Set the content's document
|
||||
content->SetDocument(mSink->mDocument, PR_FALSE);
|
||||
|
@ -2070,8 +2071,7 @@ HTMLContentSink::HTMLContentSink() {
|
|||
gSinkLogModuleInfo = PR_NewLogModule("htmlcontentsink");
|
||||
}
|
||||
#endif
|
||||
mNotAtRef = PR_TRUE;
|
||||
mContentIDCounter = NS_CONTENT_ID_COUNTER_BASE;
|
||||
mNotAtRef = PR_TRUE;
|
||||
mInScript = 0;
|
||||
mInNotification = 0;
|
||||
mInMonolithicContainer = 0;
|
||||
|
@ -3202,8 +3202,7 @@ HTMLContentSink::ProcessAREATag(const nsIParserNode& aNode)
|
|||
rv = CreateContentObject(aNode, nodeType, nsnull, nsnull, &area);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
area->SetContentID(mContentIDCounter++);
|
||||
}
|
||||
|
||||
// Set the content's document and attributes
|
||||
area->SetDocument(mDocument, PR_FALSE);
|
||||
|
@ -3279,7 +3278,9 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode)
|
|||
nsCOMPtr<nsIHTMLContent> element;
|
||||
result = NS_CreateHTMLElement(getter_AddRefs(element), tag);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
element->SetContentID(mContentIDCounter++);
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
element->SetContentID(id);
|
||||
|
||||
// Add in the attributes and add the style content object to the
|
||||
// head container.
|
||||
|
@ -3619,7 +3620,9 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
|
|||
nsIHTMLContent* element = nsnull;
|
||||
result = NS_CreateHTMLElement(&element, tag);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
element->SetContentID(mContentIDCounter++);
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
element->SetContentID(id);
|
||||
|
||||
// Add in the attributes and add the style content object to the
|
||||
// head container.
|
||||
|
@ -4245,7 +4248,9 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
nsIHTMLContent* element = nsnull;
|
||||
rv = NS_CreateHTMLElement(&element, tag);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
element->SetContentID(mContentIDCounter++);
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
element->SetContentID(id);
|
||||
|
||||
// Add in the attributes and add the style content object to the
|
||||
// head container.
|
||||
|
@ -4373,7 +4378,9 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode)
|
|||
nsIHTMLContent* element = nsnull;
|
||||
rv = NS_CreateHTMLElement(&element, tag);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
element->SetContentID(mContentIDCounter++);
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
element->SetContentID(id);
|
||||
|
||||
// Add in the attributes and add the style content object to the
|
||||
// head container.
|
||||
|
|
|
@ -1213,6 +1213,7 @@ nsHTMLDocument::CreateElement(const nsString& aTagName,
|
|||
nsCOMPtr<nsIHTMLContent> content;
|
||||
nsresult rv = NS_CreateHTMLElement(getter_AddRefs(content), aTagName);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
content->SetContentID(mNextContentID++);
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
}
|
||||
return rv;
|
||||
|
|
|
@ -736,6 +736,9 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)
|
|||
}
|
||||
|
||||
if (NS_OK == result) {
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
content->SetContentID(id);
|
||||
content->SetDocument(mDocument, PR_FALSE);
|
||||
|
||||
// Set the attributes on the new content element
|
||||
|
|
|
@ -690,6 +690,7 @@ nsXMLDocument::CreateElementWithNameSpace(const nsString& aTagName,
|
|||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
content->SetContentID(mNextContentID++);
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -1755,6 +1755,13 @@ nsXULDocument::FlushPendingNotifications()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetAndIncrementContentID(PRInt32* aID)
|
||||
{
|
||||
*aID = mNextContentID++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXULDocument::BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
|
||||
{
|
||||
|
|
|
@ -248,6 +248,8 @@ public:
|
|||
|
||||
NS_IMETHOD FlushPendingNotifications();
|
||||
|
||||
NS_IMETHOD GetAndIncrementContentID(PRInt32* aID);
|
||||
|
||||
virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
|
||||
virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
|
|
|
@ -80,6 +80,12 @@ public:
|
|||
};
|
||||
#endif
|
||||
|
||||
// The base value for the content ID counter.
|
||||
// This counter is used by the document to
|
||||
// assign a monotonically increasing ID to each content
|
||||
// object it creates
|
||||
#define NS_CONTENT_ID_COUNTER_BASE 10000
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Document interface
|
||||
|
@ -311,9 +317,9 @@ public:
|
|||
PRUint32 aFlags,
|
||||
nsEventStatus* aEventStatus) = 0;
|
||||
|
||||
|
||||
NS_IMETHOD FlushPendingNotifications() = 0;
|
||||
|
||||
NS_IMETHOD GetAndIncrementContentID(PRInt32* aID) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -591,6 +591,7 @@ nsDocument::nsDocument()
|
|||
mModCount = 0;
|
||||
mFileSpec = nsnull;
|
||||
mPrincipal = nsnull;
|
||||
mNextContentID = NS_CONTENT_ID_COUNTER_BASE;
|
||||
Init();/* XXX */
|
||||
}
|
||||
|
||||
|
@ -3056,6 +3057,14 @@ nsDocument::FlushPendingNotifications()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetAndIncrementContentID(PRInt32* aID)
|
||||
{
|
||||
*aID = mNextContentID++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetModCount(PRInt32 *outModCount)
|
||||
{
|
||||
|
|
|
@ -318,6 +318,7 @@ public:
|
|||
virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
|
||||
NS_IMETHOD FlushPendingNotifications();
|
||||
NS_IMETHOD GetAndIncrementContentID(PRInt32* aID);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -489,7 +490,10 @@ protected:
|
|||
nsVoidArray *mEpilog;
|
||||
nsDocumentChildNodes* mChildNodes;
|
||||
nsIWordBreaker* mWordBreaker;
|
||||
|
||||
// A content ID counter used to give a monotonically increasing ID to the content
|
||||
// objects in the document's content model
|
||||
PRInt32 mNextContentID;
|
||||
|
||||
// disk file members
|
||||
nsFileSpec* mFileSpec;
|
||||
PRInt32 mModCount;
|
||||
|
|
|
@ -299,6 +299,13 @@ nsGenericHTMLElement::CopyInnerTo(nsIContent* aSrcContent,
|
|||
result = mAttributes->Clone(&(aDst->mAttributes));
|
||||
}
|
||||
|
||||
PRInt32 id;
|
||||
if (mDocument) {
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
}
|
||||
if (aDst && aDst->mContent) {
|
||||
aDst->mContent->SetContentID(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -334,7 +334,6 @@ public:
|
|||
nsString mPreferredStyle;
|
||||
PRInt32 mStyleSheetCount;
|
||||
nsICSSLoader* mCSSLoader;
|
||||
PRUint32 mContentIDCounter;
|
||||
PRInt32 mInsideNoXXXTag;
|
||||
PRInt32 mInMonolithicContainer;
|
||||
|
||||
|
@ -970,6 +969,10 @@ HTMLContentSink::CreateContentObject(const nsIParserNode& aNode,
|
|||
}
|
||||
rv = MakeContentObject(aNodeType, atom, aForm, aWebShell,
|
||||
aResult, &content);
|
||||
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
(*aResult)->SetContentID(id);
|
||||
|
||||
NS_RELEASE(atom);
|
||||
}
|
||||
|
@ -1261,7 +1264,6 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
|
|||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
content->SetContentID(mSink->mContentIDCounter++);
|
||||
|
||||
nsresult srv;
|
||||
nsCOMPtr<nsISelectElement> select = do_QueryInterface(content, &srv);
|
||||
|
@ -1617,8 +1619,7 @@ SinkContext::AddLeaf(const nsIParserNode& aNode)
|
|||
&content);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
content->SetContentID(mSink->mContentIDCounter++);
|
||||
}
|
||||
|
||||
// Set the content's document
|
||||
content->SetDocument(mSink->mDocument, PR_FALSE);
|
||||
|
@ -2070,8 +2071,7 @@ HTMLContentSink::HTMLContentSink() {
|
|||
gSinkLogModuleInfo = PR_NewLogModule("htmlcontentsink");
|
||||
}
|
||||
#endif
|
||||
mNotAtRef = PR_TRUE;
|
||||
mContentIDCounter = NS_CONTENT_ID_COUNTER_BASE;
|
||||
mNotAtRef = PR_TRUE;
|
||||
mInScript = 0;
|
||||
mInNotification = 0;
|
||||
mInMonolithicContainer = 0;
|
||||
|
@ -3202,8 +3202,7 @@ HTMLContentSink::ProcessAREATag(const nsIParserNode& aNode)
|
|||
rv = CreateContentObject(aNode, nodeType, nsnull, nsnull, &area);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
area->SetContentID(mContentIDCounter++);
|
||||
}
|
||||
|
||||
// Set the content's document and attributes
|
||||
area->SetDocument(mDocument, PR_FALSE);
|
||||
|
@ -3279,7 +3278,9 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode)
|
|||
nsCOMPtr<nsIHTMLContent> element;
|
||||
result = NS_CreateHTMLElement(getter_AddRefs(element), tag);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
element->SetContentID(mContentIDCounter++);
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
element->SetContentID(id);
|
||||
|
||||
// Add in the attributes and add the style content object to the
|
||||
// head container.
|
||||
|
@ -3619,7 +3620,9 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode)
|
|||
nsIHTMLContent* element = nsnull;
|
||||
result = NS_CreateHTMLElement(&element, tag);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
element->SetContentID(mContentIDCounter++);
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
element->SetContentID(id);
|
||||
|
||||
// Add in the attributes and add the style content object to the
|
||||
// head container.
|
||||
|
@ -4245,7 +4248,9 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
|||
nsIHTMLContent* element = nsnull;
|
||||
rv = NS_CreateHTMLElement(&element, tag);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
element->SetContentID(mContentIDCounter++);
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
element->SetContentID(id);
|
||||
|
||||
// Add in the attributes and add the style content object to the
|
||||
// head container.
|
||||
|
@ -4373,7 +4378,9 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode)
|
|||
nsIHTMLContent* element = nsnull;
|
||||
rv = NS_CreateHTMLElement(&element, tag);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
element->SetContentID(mContentIDCounter++);
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
element->SetContentID(id);
|
||||
|
||||
// Add in the attributes and add the style content object to the
|
||||
// head container.
|
||||
|
|
|
@ -1213,6 +1213,7 @@ nsHTMLDocument::CreateElement(const nsString& aTagName,
|
|||
nsCOMPtr<nsIHTMLContent> content;
|
||||
nsresult rv = NS_CreateHTMLElement(getter_AddRefs(content), aTagName);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
content->SetContentID(mNextContentID++);
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
}
|
||||
return rv;
|
||||
|
|
|
@ -736,6 +736,9 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode)
|
|||
}
|
||||
|
||||
if (NS_OK == result) {
|
||||
PRInt32 id;
|
||||
mDocument->GetAndIncrementContentID(&id);
|
||||
content->SetContentID(id);
|
||||
content->SetDocument(mDocument, PR_FALSE);
|
||||
|
||||
// Set the attributes on the new content element
|
||||
|
|
|
@ -690,6 +690,7 @@ nsXMLDocument::CreateElementWithNameSpace(const nsString& aTagName,
|
|||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
content->SetContentID(mNextContentID++);
|
||||
rv = content->QueryInterface(kIDOMElementIID, (void**)aReturn);
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -1755,6 +1755,13 @@ nsXULDocument::FlushPendingNotifications()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetAndIncrementContentID(PRInt32* aID)
|
||||
{
|
||||
*aID = mNextContentID++;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsXULDocument::BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
|
||||
{
|
||||
|
|
|
@ -248,6 +248,8 @@ public:
|
|||
|
||||
NS_IMETHOD FlushPendingNotifications();
|
||||
|
||||
NS_IMETHOD GetAndIncrementContentID(PRInt32* aID);
|
||||
|
||||
virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
|
||||
virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
|
||||
|
|
Загрузка…
Ссылка в новой задаче