From 5d17ec2995fe32ec56afb10037afbdab628e4152 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Wed, 2 Feb 2005 23:16:02 +0000 Subject: [PATCH] Remove unneeded nsIContentList interface (bug 280746). r+sr=jst. git-svn-id: svn://10.0.0.236/trunk@168732 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/Makefile.in | 1 - mozilla/content/base/public/nsIContentList.h | 78 ------------------- mozilla/content/base/src/Makefile.in | 1 + mozilla/content/base/src/nsContentList.cpp | 17 ++-- mozilla/content/base/src/nsContentList.h | 33 ++++---- mozilla/content/base/src/nsContentUtils.cpp | 12 +-- mozilla/content/base/src/nsDocument.cpp | 21 ++--- mozilla/content/base/src/nsGenericElement.cpp | 22 +++--- .../html/content/src/nsHTMLFormElement.cpp | 2 +- .../html/content/src/nsHTMLMapElement.cpp | 5 +- .../html/content/src/nsHTMLTableElement.cpp | 5 +- .../content/src/nsHTMLTableRowElement.cpp | 5 +- .../content/src/nsHTMLTableSectionElement.cpp | 5 +- .../html/document/src/nsHTMLDocument.cpp | 29 +++---- .../html/document/src/nsHTMLDocument.h | 6 +- .../html/document/src/nsIHTMLDocument.h | 11 ++- .../content/xul/content/src/nsXULElement.cpp | 5 +- .../xul/document/src/nsXULDocument.cpp | 17 ++-- 18 files changed, 102 insertions(+), 173 deletions(-) delete mode 100644 mozilla/content/base/public/nsIContentList.h diff --git a/mozilla/content/base/public/Makefile.in b/mozilla/content/base/public/Makefile.in index 80082a7c7b6..be7025f6070 100644 --- a/mozilla/content/base/public/Makefile.in +++ b/mozilla/content/base/public/Makefile.in @@ -69,7 +69,6 @@ nsIContentSerializer.h \ nsIHTMLToTextSink.h \ nsIXPathEvaluatorInternal.h \ mozISanitizingSerializer.h \ -nsIContentList.h \ nsIFrameLoader.h \ nsContentCID.h \ nsCopySupport.h \ diff --git a/mozilla/content/base/public/nsIContentList.h b/mozilla/content/base/public/nsIContentList.h deleted file mode 100644 index 5e31da2b170..00000000000 --- a/mozilla/content/base/public/nsIContentList.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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/MPL/ - * - * 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.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIContentList_h___ -#define nsIContentList_h___ - -#include "nsISupports.h" -#include "nsIContent.h" -#include "nsIDOMNode.h" -#include "nsCOMPtr.h" - -// d72cb400-4b33-11d5-a041-0010a4ef48c9 -#define NS_ICONTENTLIST_IID \ -{ 0xd72cb400, 0x4b33, 0x11d5, { 0xa0, 0x41, 0x0, 0x10, 0xa4, 0xef, 0x48, 0xc9 } } - -/** - * Interface for content list. - */ -class nsIContentList : public nsISupports -{ -public: - NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICONTENTLIST_IID) - - /** - * Returns the object that the content list should be parented to. - */ - virtual nsISupports *GetParentObject() = 0; - - // Callers will want to pass in PR_TRUE for aDoFlush unless they - // are explicitly avoiding an FlushPendingNotifications. The - // flush guarantees that the list will be up to date. - - virtual PRUint32 Length(PRBool aDoFlush) = 0; - - virtual nsIContent *Item(PRUint32 aIndex, PRBool aDoFlush) = 0; - - virtual nsIContent *NamedItem(const nsAString& aName, PRBool aDoFlush) = 0; - - virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush) = 0; - - virtual void RootDestroyed() = 0; -}; - -#endif /* nsIContentList_h___ */ diff --git a/mozilla/content/base/src/Makefile.in b/mozilla/content/base/src/Makefile.in index 8849fd979ca..f2d938e33b6 100644 --- a/mozilla/content/base/src/Makefile.in +++ b/mozilla/content/base/src/Makefile.in @@ -82,6 +82,7 @@ REQUIRES = xpcom \ EXPORTS = \ nsAtomListUtils.h \ + nsContentList.h \ nsNodeInfoManager.h \ nsPropertyTable.h \ nsStubDocumentObserver.h \ diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index f733b0402bc..2089faf77e9 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -49,12 +49,11 @@ // Form related includes #include "nsIDOMHTMLFormElement.h" -#include "nsIContentList.h" #include "pldhash.h" -static nsIContentList *gCachedContentList; +static nsContentList *gCachedContentList; nsBaseContentList::nsBaseContentList() { @@ -236,12 +235,10 @@ ContentListHashtableMatchEntry(PLDHashTable *table, return list1->Equals(*list2); } -nsresult +already_AddRefed NS_GetContentList(nsIDocument* aDocument, nsIAtom* aMatchAtom, - PRInt32 aMatchNameSpaceId, nsIContent* aRootContent, - nsIContentList** aInstancePtrResult) + PRInt32 aMatchNameSpaceId, nsIContent* aRootContent) { - *aInstancePtrResult = nsnull; nsContentList* list = nsnull; static PLDHashTableOps hash_table_ops = @@ -296,11 +293,10 @@ NS_GetContentList(nsIDocument* aDocument, nsIAtom* aMatchAtom, PL_DHashTableRawRemove(&gContentListHashTable, entry); } - NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); + NS_ENSURE_TRUE(list, nsnull); } - *aInstancePtrResult = list; - NS_ADDREF(*aInstancePtrResult); + NS_ADDREF(list); // Hold on to the last requested content list to avoid having it be // removed from the cache immediately when it's released. Avoid @@ -314,7 +310,7 @@ NS_GetContentList(nsIDocument* aDocument, nsIAtom* aMatchAtom, NS_ADDREF(gCachedContentList); } - return NS_OK; + return list; } @@ -395,7 +391,6 @@ nsContentList::~nsContentList() // QueryInterface implementation for nsContentList NS_INTERFACE_MAP_BEGIN(nsContentList) NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLCollection) - NS_INTERFACE_MAP_ENTRY(nsIContentList) NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(ContentList) NS_INTERFACE_MAP_END_INHERITING(nsBaseContentList) diff --git a/mozilla/content/base/src/nsContentList.h b/mozilla/content/base/src/nsContentList.h index 8b771c550dd..3d08734ce72 100644 --- a/mozilla/content/base/src/nsContentList.h +++ b/mozilla/content/base/src/nsContentList.h @@ -43,7 +43,6 @@ #include "nsIDOMHTMLCollection.h" #include "nsIDOMNodeList.h" #include "nsStubDocumentObserver.h" -#include "nsIContentList.h" #include "nsIAtom.h" #include "nsINameSpaceManager.h" @@ -158,8 +157,7 @@ protected: class nsContentList : public nsBaseContentList, protected nsContentListKey, public nsIDOMHTMLCollection, - public nsStubDocumentObserver, - public nsIContentList + public nsStubDocumentObserver { public: NS_DECL_ISUPPORTS_INHERITED @@ -181,13 +179,20 @@ public: // nsIDOMHTMLCollection NS_DECL_NSIDOMHTMLCOLLECTION - /// nsIContentList - virtual nsISupports *GetParentObject(); - virtual PRUint32 Length(PRBool aDoFlush); - virtual nsIContent *Item(PRUint32 aIndex, PRBool aDoFlush); - virtual nsIContent *NamedItem(const nsAString& aName, PRBool aDoFlush); + // nsBaseContentList overrides virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush); - virtual void RootDestroyed(); + + // nsContentList public methods + NS_HIDDEN_(nsISupports*) GetParentObject(); + NS_HIDDEN_(PRUint32) Length(PRBool aDoFlush); + NS_HIDDEN_(nsIContent*) Item(PRUint32 aIndex, PRBool aDoFlush); + NS_HIDDEN_(nsIContent*) NamedItem(const nsAString& aName, PRBool aDoFlush); + NS_HIDDEN_(void) RootDestroyed(); + + nsContentListKey* GetKey() { + return NS_STATIC_CAST(nsContentListKey*, this); + } + // nsIDocumentObserver virtual void AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, @@ -201,11 +206,6 @@ public: nsIContent* aChild, PRInt32 aIndexInContainer); virtual void DocumentWillBeDestroyed(nsIDocument *aDocument); - // Other public methods - nsContentListKey* GetKey() { - return NS_STATIC_CAST(nsContentListKey*, this); - } - protected: void Init(nsIDocument *aDocument); /** @@ -355,9 +355,8 @@ protected: */ #define LIST_LAZY 2 -nsresult +already_AddRefed NS_GetContentList(nsIDocument* aDocument, nsIAtom* aMatchAtom, - PRInt32 aMatchNameSpaceId, nsIContent* aRootContent, - nsIContentList** aInstancePtrResult); + PRInt32 aMatchNameSpaceId, nsIContent* aRootContent); #endif // nsContentList_h___ diff --git a/mozilla/content/base/src/nsContentUtils.cpp b/mozilla/content/base/src/nsContentUtils.cpp index 19470dc3f1f..1d6463350e1 100644 --- a/mozilla/content/base/src/nsContentUtils.cpp +++ b/mozilla/content/base/src/nsContentUtils.cpp @@ -78,7 +78,7 @@ #include "nsIParserService.h" #include "nsIServiceManager.h" #include "nsIAttribute.h" -#include "nsIContentList.h" +#include "nsContentList.h" #include "nsIHTMLDocument.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLCollection.h" @@ -1425,16 +1425,12 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent, if (htmlDocument) { // Flush our content model so it'll be up to date aContent->GetCurrentDoc()->FlushPendingNotifications(Flush_Content); - nsCOMPtr domHtmlDocument(do_QueryInterface(htmlDocument)); - nsCOMPtr forms; - domHtmlDocument->GetForms(getter_AddRefs(forms)); - nsCOMPtr htmlForms(do_QueryInterface(forms)); - nsCOMPtr formControls = + nsContentList *htmlForms = htmlDocument->GetForms(); + nsRefPtr htmlFormControls = htmlDocument->GetFormControlElements(); - NS_ENSURE_TRUE(formControls, NS_ERROR_OUT_OF_MEMORY); - nsCOMPtr htmlFormControls(do_QueryInterface(formControls)); + NS_ENSURE_TRUE(htmlForms && htmlFormControls, NS_ERROR_OUT_OF_MEMORY); // If we have a form control and can calculate form information, use // that as the key - it is more reliable than contentID. diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 3d0788689c8..50ef0669ca3 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -2448,12 +2448,13 @@ nsDocument::GetElementsByTagName(const nsAString& aTagname, nsCOMPtr nameAtom = do_GetAtom(aTagname); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); - nsCOMPtr list; - NS_GetContentList(this, nameAtom, kNameSpaceID_Unknown, nsnull, - getter_AddRefs(list)); + nsContentList *list = NS_GetContentList(this, nameAtom, kNameSpaceID_Unknown, + nsnull).get(); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); - return CallQueryInterface(list, aReturn); + // transfer ref to aReturn + *aReturn = list; + return NS_OK; } NS_IMETHODIMP @@ -2463,7 +2464,7 @@ nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI, { PRInt32 nameSpaceId = kNameSpaceID_Unknown; - nsCOMPtr list; + nsContentList *list = nsnull; if (!aNamespaceURI.EqualsLiteral("*")) { nsContentUtils::GetNSManagerWeakRef()->GetNameSpaceID(aNamespaceURI, @@ -2471,8 +2472,7 @@ nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI, if (nameSpaceId == kNameSpaceID_Unknown) { // Unknown namespace means no matches, we create an empty list... - NS_GetContentList(this, nsnull, kNameSpaceID_None, nsnull, - getter_AddRefs(list)); + list = NS_GetContentList(this, nsnull, kNameSpaceID_None, nsnull).get(); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); } } @@ -2481,12 +2481,13 @@ nsDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI, nsCOMPtr nameAtom = do_GetAtom(aLocalName); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); - NS_GetContentList(this, nameAtom, nameSpaceId, nsnull, - getter_AddRefs(list)); + list = NS_GetContentList(this, nameAtom, nameSpaceId, nsnull).get(); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); } - return CallQueryInterface(list, aReturn); + // transfer ref to aReturn + *aReturn = list; + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 39c24ae3683..1606502416d 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -1431,12 +1431,13 @@ nsGenericElement::GetElementsByTagName(const nsAString& aTagname, nsCOMPtr nameAtom = do_GetAtom(aTagname); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); - nsCOMPtr list; - NS_GetContentList(GetCurrentDoc(), nameAtom, kNameSpaceID_Unknown, this, - getter_AddRefs(list)); + nsContentList *list = NS_GetContentList(GetCurrentDoc(), nameAtom, + kNameSpaceID_Unknown, this).get(); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); - return CallQueryInterface(list, aReturn); + // transfer ref to aReturn + *aReturn = list; + return NS_OK; } nsresult @@ -1552,7 +1553,7 @@ nsGenericElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI, { PRInt32 nameSpaceId = kNameSpaceID_Unknown; - nsCOMPtr list; + nsContentList *list = nsnull; nsIDocument* document = GetCurrentDoc(); if (!aNamespaceURI.EqualsLiteral("*")) { @@ -1561,8 +1562,8 @@ nsGenericElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI, if (nameSpaceId == kNameSpaceID_Unknown) { // Unknown namespace means no matches, we create an empty list... - NS_GetContentList(document, nsnull, kNameSpaceID_None, nsnull, - getter_AddRefs(list)); + list = NS_GetContentList(document, nsnull, + kNameSpaceID_None, nsnull).get(); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); } } @@ -1571,12 +1572,13 @@ nsGenericElement::GetElementsByTagNameNS(const nsAString& aNamespaceURI, nsCOMPtr nameAtom = do_GetAtom(aLocalName); NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY); - NS_GetContentList(document, nameAtom, nameSpaceId, this, - getter_AddRefs(list)); + list = NS_GetContentList(document, nameAtom, nameSpaceId, this).get(); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); } - return CallQueryInterface(list, aReturn); + // transfer ref to aReturn + *aReturn = list; + return NS_OK; } nsresult diff --git a/mozilla/content/html/content/src/nsHTMLFormElement.cpp b/mozilla/content/html/content/src/nsHTMLFormElement.cpp index 7e82f6fc4be..d7702b30838 100644 --- a/mozilla/content/html/content/src/nsHTMLFormElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLFormElement.cpp @@ -1497,7 +1497,7 @@ nsHTMLFormElement::GetNextRadioButton(const nsAString& aName, nsCOMPtr radioNodeList(do_QueryInterface(itemWithName)); // XXX If ResolveName could return an nsContentList instead then we - // could get an nsIContentList instead of using this hacky upcast + // could get an nsContentList instead of using this hacky upcast nsBaseContentList *radioGroup = NS_STATIC_CAST(nsBaseContentList *, (nsIDOMNodeList *)radioNodeList); diff --git a/mozilla/content/html/content/src/nsHTMLMapElement.cpp b/mozilla/content/html/content/src/nsHTMLMapElement.cpp index 9d9f6385b04..57bba5ec2e5 100644 --- a/mozilla/content/html/content/src/nsHTMLMapElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLMapElement.cpp @@ -72,7 +72,7 @@ public: PRBool aCompileEventHandlers); protected: - nsCOMPtr mAreas; + nsRefPtr mAreas; }; @@ -152,8 +152,7 @@ nsHTMLMapElement::GetAreas(nsIDOMHTMLCollection** aAreas) } } - CallQueryInterface(mAreas, aAreas); - + NS_ADDREF(*aAreas = mAreas); return NS_OK; } diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp index 36d7a46786b..f6788a793b2 100644 --- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -90,7 +90,7 @@ public: protected: already_AddRefed GetSection(nsIAtom *aTag); - nsCOMPtr mTBodies; + nsRefPtr mTBodies; TableRowsCollection *mRows; }; @@ -495,7 +495,8 @@ nsHTMLTableElement::GetTBodies(nsIDOMHTMLCollection** aValue) NS_ENSURE_TRUE(mTBodies, NS_ERROR_OUT_OF_MEMORY); } - return CallQueryInterface(mTBodies, aValue); + NS_ADDREF(*aValue = mTBodies); + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp index 97d7c3a182d..dbf94bf888b 100644 --- a/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableRowElement.cpp @@ -85,7 +85,7 @@ public: protected: nsresult GetSection(nsIDOMHTMLTableSectionElement** aSection); nsresult GetTable(nsIDOMHTMLTableElement** aTable); - nsCOMPtr mCells; + nsRefPtr mCells; }; #ifdef XXX_debugging @@ -272,7 +272,8 @@ nsHTMLTableRowElement::GetCells(nsIDOMHTMLCollection** aValue) NS_ENSURE_TRUE(mCells, NS_ERROR_OUT_OF_MEMORY); } - return CallQueryInterface(mCells, aValue); + NS_ADDREF(*aValue = mCells); + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp index 5d52df81a6a..0cc10b8af2a 100644 --- a/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -78,7 +78,7 @@ public: NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; protected: - nsCOMPtr mRows; + nsRefPtr mRows; }; @@ -134,7 +134,8 @@ nsHTMLTableSectionElement::GetRows(nsIDOMHTMLCollection** aValue) NS_ENSURE_TRUE(mRows, NS_ERROR_OUT_OF_MEMORY); } - return CallQueryInterface(mRows, aValue); + NS_ADDREF(*aValue = mRows); + return NS_OK; } diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 45d26bf688a..b444e40d26b 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -2465,13 +2465,12 @@ nsHTMLDocument::MatchFormControls(nsIContent* aContent, PRInt32 aNamespaceID, return aContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL); } -already_AddRefed +already_AddRefed nsHTMLDocument::GetFormControlElements() { - nsIDOMNodeList *list = new nsContentList(this, MatchFormControls, - EmptyString()); + nsContentList *list = new nsContentList(this, + MatchFormControls, EmptyString()); NS_IF_ADDREF(list); - return list; } @@ -3393,19 +3392,23 @@ nsHTMLDocument::GetBodyElement(nsIDOMHTMLBodyElement** aBody) NS_IMETHODIMP nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms) { - if (!mForms) { - mForms = new nsContentList(this, nsHTMLAtoms::form, mDefaultNamespaceID); - if (!mForms) { - return NS_ERROR_OUT_OF_MEMORY; - } - } - - *aForms = mForms; - NS_ADDREF(*aForms); + nsContentList *forms = nsHTMLDocument::GetForms(); + if (!forms) + return NS_ERROR_OUT_OF_MEMORY; + NS_ADDREF(*aForms = forms); return NS_OK; } +nsContentList* +nsHTMLDocument::GetForms() +{ + if (!mForms) + mForms = new nsContentList(this, nsHTMLAtoms::form, mDefaultNamespaceID); + + return mForms; +} + nsresult nsHTMLDocument::CreateAndAddWyciwygChannel(void) diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 3b0037b6e86..434d1eaf775 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -122,6 +122,8 @@ public: virtual PRBool GetIsFrameset() { return mIsFrameset; } virtual void SetIsFrameset(PRBool aFrameset) { mIsFrameset = aFrameset; } + virtual NS_HIDDEN_(nsContentList*) GetForms(); + virtual void ContentAppended(nsIContent* aContainer, PRInt32 aNewIndexInContainer); virtual void ContentInserted(nsIContent* aContainer, @@ -191,7 +193,7 @@ public: nsIDOMHTMLFormElement *aForm, nsISupports **aResult); - virtual already_AddRefed GetFormControlElements(); + virtual already_AddRefed GetFormControlElements(); virtual void AddedForm(); virtual void RemovedForm(); virtual PRInt32 GetNumFormsSynchronous(); @@ -270,7 +272,7 @@ protected: nsCOMPtr mEmbeds; nsCOMPtr mLinks; nsCOMPtr mAnchors; - nsCOMPtr mForms; + nsRefPtr mForms; nsCOMPtr mParser; diff --git a/mozilla/content/html/document/src/nsIHTMLDocument.h b/mozilla/content/html/document/src/nsIHTMLDocument.h index 12eae9914b5..55dc1648b03 100644 --- a/mozilla/content/html/document/src/nsIHTMLDocument.h +++ b/mozilla/content/html/document/src/nsIHTMLDocument.h @@ -39,6 +39,7 @@ #include "nsISupports.h" #include "nsCompatibility.h" +#include "nsContentList.h" class nsIImageMap; class nsString; @@ -52,9 +53,8 @@ class nsICSSLoader; class nsIContent; class nsIDOMHTMLBodyElement; -/* 30dc35c0-75b5-4e96-a828-54470ce86726 */ #define NS_IHTMLDOCUMENT_IID \ -{0x30dc35c0, 0x75b5, 0x4e96, {0xa8, 0x28, 0x54, 0x47, 0x0c, 0xe8, 0x67, 0x26}} +{0x0c548e6b, 0xf3b4, 0x489b, {0xb7, 0xda, 0xac, 0xdb, 0x2c, 0x89, 0xab, 0xc0}} /** @@ -90,7 +90,7 @@ public: * This method returns null if we run out of memory. Callers should * check for null. */ - virtual already_AddRefed GetFormControlElements() = 0; + virtual already_AddRefed GetFormControlElements() = 0; /** * Called when form->SetDocument() is called so that document knows @@ -114,6 +114,11 @@ public: virtual PRBool GetIsFrameset() = 0; virtual void SetIsFrameset(PRBool aFrameset) = 0; + + /** + * Get the list of form elements in the document. + */ + virtual nsContentList* GetForms() = 0; }; #endif /* nsIHTMLDocument_h___ */ diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 994032f1335..6148f11eaf6 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -591,7 +591,7 @@ nsXULElement::GetElementsByAttribute(const nsAString& aAttribute, nsCOMPtr attrAtom(do_GetAtom(aAttribute)); NS_ENSURE_TRUE(attrAtom, NS_ERROR_OUT_OF_MEMORY); - nsCOMPtr list = + nsContentList *list = new nsContentList(GetDocument(), nsXULDocument::MatchAttribute, aValue, @@ -601,7 +601,8 @@ nsXULElement::GetElementsByAttribute(const nsAString& aAttribute, kNameSpaceID_None); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); - return CallQueryInterface(list, aReturn); + NS_ADDREF(*aReturn = list); + return NS_OK; } diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 6282acfb9b1..7dcccc52031 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1409,16 +1409,17 @@ nsXULDocument::GetElementsByAttribute(const nsAString& aAttribute, nsCOMPtr attrAtom(do_GetAtom(aAttribute)); NS_ENSURE_TRUE(attrAtom, NS_ERROR_OUT_OF_MEMORY); - nsCOMPtr list = new nsContentList(this, - MatchAttribute, - aValue, - nsnull, - PR_TRUE, - attrAtom, - kNameSpaceID_None); + nsContentList *list = new nsContentList(this, + MatchAttribute, + aValue, + nsnull, + PR_TRUE, + attrAtom, + kNameSpaceID_None); NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY); - return CallQueryInterface(list, aReturn); + NS_ADDREF(*aReturn = list); + return NS_OK; }