From cc3124a08769bdadf74bd197599a78097dde6016 Mon Sep 17 00:00:00 2001 From: David Zbarsky Date: Sat, 8 Dec 2012 17:06:42 -0500 Subject: [PATCH] Bug 817332 - Remove XPIDL for HTMLPropertiesCollection/PropertyNodeList r=bz --- .../content/src/HTMLPropertiesCollection.cpp | 79 +++---------------- .../content/src/HTMLPropertiesCollection.h | 44 +++++------ content/html/content/src/Makefile.in | 1 + .../html/content/src/nsGenericHTMLElement.cpp | 4 +- .../html/content/src/nsGenericHTMLElement.h | 8 +- dom/base/nsDOMClassInfo.cpp | 19 ----- dom/base/nsDOMClassInfoClasses.h | 2 - dom/interfaces/html/Makefile.in | 2 - dom/interfaces/html/nsIDOMHTMLElement.idl | 3 +- .../html/nsIDOMHTMLPropertiesCollection.idl | 20 ----- .../html/nsIDOMPropertyNodeList.idl | 16 ---- 11 files changed, 40 insertions(+), 158 deletions(-) delete mode 100644 dom/interfaces/html/nsIDOMHTMLPropertiesCollection.idl delete mode 100644 dom/interfaces/html/nsIDOMPropertyNodeList.idl diff --git a/content/html/content/src/HTMLPropertiesCollection.cpp b/content/html/content/src/HTMLPropertiesCollection.cpp index 8cbbe3a5065..767615f340c 100644 --- a/content/html/content/src/HTMLPropertiesCollection.cpp +++ b/content/html/content/src/HTMLPropertiesCollection.cpp @@ -24,7 +24,7 @@ static PLDHashOperator TraverseNamedProperties(const nsAString& aKey, PropertyNodeList* aEntry, void* aData) { nsCycleCollectionTraversalCallback* cb = static_cast(aData); - cb->NoteXPCOMChild(static_cast(aEntry)); + cb->NoteXPCOMChild(static_cast(aEntry)); return PL_DHASH_NEXT; } @@ -72,13 +72,11 @@ HTMLPropertiesCollection::~HTMLPropertiesCollection() NS_INTERFACE_TABLE_HEAD(HTMLPropertiesCollection) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_TABLE4(HTMLPropertiesCollection, - nsIDOMHTMLPropertiesCollection, + NS_INTERFACE_TABLE3(HTMLPropertiesCollection, nsIDOMHTMLCollection, nsIHTMLCollection, nsIMutationObserver) NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(HTMLPropertiesCollection) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLPropertiesCollection) NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(HTMLPropertiesCollection) @@ -178,21 +176,6 @@ HTMLPropertiesCollection::NamedItem(const nsAString& aName) return propertyList; } -NS_IMETHODIMP -HTMLPropertiesCollection::NamedItem(const nsAString& aName, - nsIDOMPropertyNodeList** aResult) -{ - NS_ADDREF(*aResult = NamedItem(aName)); - return NS_OK; -} - -NS_IMETHODIMP -HTMLPropertiesCollection::GetNames(nsIDOMDOMStringList** aResult) -{ - NS_ADDREF(*aResult = Names()); - return NS_OK; -} - void HTMLPropertiesCollection::AttributeChanged(nsIDocument *aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, @@ -282,7 +265,7 @@ HTMLPropertiesCollection::EnsureFresh() } } } - + static Element* GetElementByIdForConnectedSubtree(nsIContent* aContent, const nsIAtom* aId) { @@ -293,7 +276,7 @@ GetElementByIdForConnectedSubtree(nsIContent* aContent, const nsIAtom* aId) } aContent = aContent->GetNextNode(); } while(aContent); - + return NULL; } @@ -301,7 +284,7 @@ void HTMLPropertiesCollection::CrawlProperties() { nsIDocument* doc = mRoot->GetCurrentDoc(); - + const nsAttrValue* attr = mRoot->GetParsedAttr(nsGkAtoms::itemref); if (attr) { for (uint32_t i = 0; i < attr->GetAtomCount(); i++) { @@ -317,7 +300,7 @@ HTMLPropertiesCollection::CrawlProperties() } } } - + CrawlSubtree(mRoot); } @@ -337,15 +320,15 @@ HTMLPropertiesCollection::CrawlSubtree(Element* aElement) if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::itemprop) && !mProperties.Contains(element)) { mProperties.AppendElement(static_cast(element)); - } - + } + if (element->HasAttr(kNameSpaceID_None, nsGkAtoms::itemscope)) { aContent = element->GetNextNonChildNode(aElement); - } else { + } else { aContent = element->GetNextNode(aElement); - } - } - } + } + } + } } void @@ -460,13 +443,11 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(PropertyNodeList) NS_INTERFACE_TABLE_HEAD(PropertyNodeList) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_TABLE4(PropertyNodeList, - nsIDOMPropertyNodeList, + NS_INTERFACE_TABLE3(PropertyNodeList, nsIDOMNodeList, nsINodeList, nsIMutationObserver) NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(PropertyNodeList) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PropertyNodeList) NS_INTERFACE_MAP_END void @@ -487,40 +468,6 @@ PropertyNodeList::GetValues(JSContext* aCx, nsTArray& aResult, } } -NS_IMETHODIMP -PropertyNodeList::GetValues(nsIVariant** aValues) -{ - EnsureFresh(); - nsCOMPtr out = new nsVariant(); - - // We have to use an nsTArray here and do manual refcounting because - // nsWritableVariant::SetAsArray takes an nsIVariant**. - nsTArray values; - - uint32_t length = mElements.Length(); - if (length == 0) { - out->SetAsEmptyArray(); - } else { - for (uint32_t i = 0; i < length; ++i) { - nsIVariant* itemValue; - mElements.ElementAt(i)->GetItemValue(&itemValue); - values.AppendElement(itemValue); - } - out->SetAsArray(nsIDataType::VTYPE_INTERFACE_IS, - &NS_GET_IID(nsIVariant), - values.Length(), - values.Elements()); - } - - out.forget(aValues); - - for (uint32_t i = 0; i < values.Length(); ++i) { - NS_RELEASE(values[i]); - } - - return NS_OK; -} - void PropertyNodeList::AttributeChanged(nsIDocument* aDocument, Element* aElement, int32_t aNameSpaceID, nsIAtom* aAttribute, diff --git a/content/html/content/src/HTMLPropertiesCollection.h b/content/html/content/src/HTMLPropertiesCollection.h index 99b5fc566f1..86052eff579 100644 --- a/content/html/content/src/HTMLPropertiesCollection.h +++ b/content/html/content/src/HTMLPropertiesCollection.h @@ -10,8 +10,6 @@ #include "nsDOMLists.h" #include "nsCycleCollectionParticipant.h" #include "nsAutoPtr.h" -#include "nsIDOMHTMLPropertiesCollection.h" -#include "nsIDOMPropertyNodeList.h" #include "nsCOMArray.h" #include "nsIMutationObserver.h" #include "nsStubMutationObserver.h" @@ -20,9 +18,9 @@ #include "nsIHTMLCollection.h" #include "nsHashKeys.h" #include "nsRefPtrHashtable.h" +#include "jsapi.h" class nsGenericHTMLElement; -class nsXPCClassInfo; class nsIDocument; class nsINode; @@ -48,7 +46,6 @@ protected: }; class HTMLPropertiesCollection : public nsIHTMLCollection, - public nsIDOMHTMLPropertiesCollection, public nsStubMutationObserver, public nsWrapperCache { @@ -64,7 +61,6 @@ public: virtual Element* GetElementAt(uint32_t aIndex); - NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aResult); void SetDocument(nsIDocument* aDocument); nsINode* GetParentObject(); virtual JSObject* NamedItem(JSContext* cx, const nsAString& name, @@ -82,8 +78,9 @@ public: } virtual void GetSupportedNames(nsTArray& aNames); + NS_DECL_NSIDOMHTMLCOLLECTION + NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_NSIDOMHTMLPROPERTIESCOLLECTION NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED @@ -93,12 +90,10 @@ public: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(HTMLPropertiesCollection, nsIHTMLCollection) - nsXPCClassInfo* GetClassInfo(); - protected: // Make sure this collection is up to date, in case the DOM has been mutated. void EnsureFresh(); - + // Crawl the properties of mRoot, following any itemRefs it may have void CrawlProperties(); @@ -112,26 +107,25 @@ protected: } // the items that make up this collection - nsTArray > mProperties; - + nsTArray > mProperties; + // the itemprop attribute of the properties - nsRefPtr mNames; - - // The cached PropertyNodeLists that are NamedItems of this collection + nsRefPtr mNames; + + // The cached PropertyNodeLists that are NamedItems of this collection nsRefPtrHashtable mNamedItemEntries; - + // The element this collection is rooted at nsCOMPtr mRoot; - + // The document mRoot is in, if any nsCOMPtr mDoc; - + // True if there have been DOM modifications since the last EnsureFresh call. bool mIsDirty; }; class PropertyNodeList : public nsINodeList, - public nsIDOMPropertyNodeList, public nsStubMutationObserver { public: @@ -148,12 +142,12 @@ public: ErrorResult& aError); virtual nsIContent* Item(uint32_t aIndex); - NS_DECL_NSIDOMPROPERTYNODELIST NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(PropertyNodeList, nsINodeList) + NS_DECL_NSIDOMNODELIST NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED @@ -163,24 +157,24 @@ public: // nsINodeList interface virtual int32_t IndexOf(nsIContent* aContent); virtual nsINode* GetParentObject(); - + void AppendElement(nsGenericHTMLElement* aElement) { mElements.AppendElement(aElement); } - + void Clear() { mElements.Clear(); } - + void SetDirty() { mIsDirty = true; } - + protected: // Make sure this list is up to date, in case the DOM has been mutated. void EnsureFresh(); - // the the name that this list corresponds to + // the the name that this list corresponds to nsString mName; // the document mParent is in, if any @@ -201,4 +195,4 @@ protected: } // namespace dom } // namespace mozilla -#endif // HTMLPropertiesCollection_h_ +#endif // HTMLPropertiesCollection_h_ diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index f1d2ad6f058..6bfffb840df 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -17,6 +17,7 @@ FAIL_ON_WARNINGS = 1 EXPORTS = \ + HTMLPropertiesCollection.h \ nsGenericHTMLElement.h \ nsHTMLIFrameElement.h \ nsClientRect.h \ diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index b63cc331eb5..ef203257d9e 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -4191,9 +4191,9 @@ nsGenericHTMLElement::Properties() } void -nsGenericHTMLElement::GetProperties(nsIDOMHTMLPropertiesCollection** aProperties) +nsGenericHTMLElement::GetProperties(nsISupports** aProperties) { - NS_ADDREF(*aProperties = Properties()); + NS_ADDREF(*aProperties = static_cast(Properties())); } nsSize diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index c7008dad814..58949650c94 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -37,10 +37,10 @@ class nsHTMLFormElement; class nsIDOMHTMLMenuElement; class nsIDOMHTMLCollection; class nsDOMSettableTokenList; -class nsIDOMHTMLPropertiesCollection; class nsIDOMDOMStringMap; + namespace mozilla { -namespace dom { +namespace dom{ class HTMLPropertiesCollection; } } @@ -316,7 +316,7 @@ public: NS_IMETHOD GetItemValue(nsIVariant** aValue); NS_IMETHOD SetItemValue(nsIVariant* aValue); protected: - void GetProperties(nsIDOMHTMLPropertiesCollection** aProperties); + void GetProperties(nsISupports** aProperties); void GetContextMenu(nsIDOMHTMLMenuElement** aContextMenu) const; // These methods are used to implement element-specific behavior of Get/SetItemValue @@ -1661,7 +1661,7 @@ protected: nsGenericHTMLElement::SetItemId(aId, rv); \ return rv.ErrorCode(); \ } \ - NS_IMETHOD GetProperties(nsIDOMHTMLPropertiesCollection** aReturn) \ + NS_IMETHOD GetProperties(nsISupports** aReturn) \ MOZ_FINAL { \ nsGenericHTMLElement::GetProperties(aReturn); \ return NS_OK; \ diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 0a1765e7ae5..4b4696b6dad 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -100,7 +100,6 @@ #include "nsIDOMChromeWindow.h" #include "nsIDOMConstructor.h" #include "nsClientRect.h" -#include "nsIDOMHTMLPropertiesCollection.h" // DOM core includes #include "nsError.h" @@ -314,8 +313,6 @@ #include "nsIDOMXPathNSResolver.h" #include "nsIDOMXPathResult.h" #include "nsIDOMMozBrowserFrame.h" -#include "nsIDOMHTMLPropertiesCollection.h" -#include "nsIDOMPropertyNodeList.h" #include "nsIDOMGetSVGDocument.h" #include "nsIDOMSVGAElement.h" @@ -872,12 +869,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(HTMLCollection, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(HTMLPropertiesCollection, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(PropertyNodeList, - nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) - // HTML element classes NS_DEFINE_CLASSINFO_DATA(HTMLElement, nsElementSH, ELEMENT_SCRIPTABLE_FLAGS) @@ -2681,16 +2672,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(HTMLPropertiesCollection, nsIDOMHTMLPropertiesCollection) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLPropertiesCollection) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLCollection) - DOM_CLASSINFO_MAP_END - - DOM_CLASSINFO_MAP_BEGIN(PropertyNodeList, nsIDOMPropertyNodeList) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMPropertyNodeList) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeList) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(HTMLElement, nsIDOMHTMLElement) DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLElement) DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 8d9d75ef78b..f9ad3d312a4 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -54,8 +54,6 @@ DOMCI_CLASS(DeviceRotationRate) DOMCI_CLASS(HTMLDocument) DOMCI_CLASS(HTMLOptionsCollection) DOMCI_CLASS(HTMLCollection) -DOMCI_CLASS(HTMLPropertiesCollection) -DOMCI_CLASS(PropertyNodeList) // HTML element classes DOMCI_CLASS(HTMLElement) diff --git a/dom/interfaces/html/Makefile.in b/dom/interfaces/html/Makefile.in index d97018c2bca..2a5355a50e5 100644 --- a/dom/interfaces/html/Makefile.in +++ b/dom/interfaces/html/Makefile.in @@ -62,8 +62,6 @@ SDK_XPIDLSRCS = \ nsIDOMHTMLParagraphElement.idl \ nsIDOMHTMLParamElement.idl \ nsIDOMHTMLPreElement.idl \ - nsIDOMHTMLPropertiesCollection.idl \ - nsIDOMPropertyNodeList.idl \ nsIDOMHTMLProgressElement.idl \ nsIDOMHTMLQuoteElement.idl \ nsIDOMHTMLScriptElement.idl \ diff --git a/dom/interfaces/html/nsIDOMHTMLElement.idl b/dom/interfaces/html/nsIDOMHTMLElement.idl index b104fdcb20e..ec090601a19 100644 --- a/dom/interfaces/html/nsIDOMHTMLElement.idl +++ b/dom/interfaces/html/nsIDOMHTMLElement.idl @@ -7,7 +7,6 @@ #include "nsIVariant.idl" interface nsIDOMHTMLMenuElement; -interface nsIDOMHTMLPropertiesCollection; /** * The nsIDOMHTMLElement interface is the primary [X]HTML element @@ -34,7 +33,7 @@ interface nsIDOMHTMLElement : nsIDOMElement attribute boolean itemScope; attribute nsIVariant itemType; attribute DOMString itemId; - readonly attribute nsIDOMHTMLPropertiesCollection properties; + readonly attribute nsISupports properties; // The following attributes are really nsDOMSettableTokenList, which has // PutForwards, so we express them as nsIVariants to deal with this. attribute nsIVariant itemValue; diff --git a/dom/interfaces/html/nsIDOMHTMLPropertiesCollection.idl b/dom/interfaces/html/nsIDOMHTMLPropertiesCollection.idl deleted file mode 100644 index 3d2a8e09996..00000000000 --- a/dom/interfaces/html/nsIDOMHTMLPropertiesCollection.idl +++ /dev/null @@ -1,20 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsIDOMPropertyNodeList.idl" -#include "nsIDOMDOMStringList.idl" - -// This interface should extend nsIDOMHTMLCollection, which will be fixed when -// it is converted to webidl. -[scriptable, uuid(b3a368e4-61a4-4578-94ce-57f98b0e79e8)] -interface nsIDOMHTMLPropertiesCollection : nsISupports -{ - readonly attribute unsigned long length; - readonly attribute nsIDOMDOMStringList names; - - nsIDOMNode item(in unsigned long index); - nsIDOMPropertyNodeList namedItem(in DOMString name); -}; diff --git a/dom/interfaces/html/nsIDOMPropertyNodeList.idl b/dom/interfaces/html/nsIDOMPropertyNodeList.idl deleted file mode 100644 index 6a25359f2ff..00000000000 --- a/dom/interfaces/html/nsIDOMPropertyNodeList.idl +++ /dev/null @@ -1,16 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set tw=80 expandtab softtabstop=2 ts=2 sw=2: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsIVariant.idl" - -interface nsIDOMNode; - -[scriptable, uuid(22c9c591-182d-4504-8a95-d3274a8b147a)] -interface nsIDOMPropertyNodeList : nsISupports { - nsIDOMNode item(in unsigned long index); - readonly attribute unsigned long length; - nsIVariant getValues(); -};