Bug 817332 - Remove XPIDL for HTMLPropertiesCollection/PropertyNodeList r=bz

This commit is contained in:
David Zbarsky 2012-12-08 17:06:42 -05:00
parent 8768ca2292
commit cc3124a087
11 changed files with 40 additions and 158 deletions

View File

@ -24,7 +24,7 @@ static PLDHashOperator
TraverseNamedProperties(const nsAString& aKey, PropertyNodeList* aEntry, void* aData)
{
nsCycleCollectionTraversalCallback* cb = static_cast<nsCycleCollectionTraversalCallback*>(aData);
cb->NoteXPCOMChild(static_cast<nsIDOMPropertyNodeList*>(aEntry));
cb->NoteXPCOMChild(static_cast<nsINodeList*>(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<nsGenericHTMLElement*>(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<JS::Value >& aResult,
}
}
NS_IMETHODIMP
PropertyNodeList::GetValues(nsIVariant** aValues)
{
EnsureFresh();
nsCOMPtr<nsIWritableVariant> out = new nsVariant();
// We have to use an nsTArray<nsIVariant*> here and do manual refcounting because
// nsWritableVariant::SetAsArray takes an nsIVariant**.
nsTArray<nsIVariant*> 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,

View File

@ -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<nsString>& 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<nsRefPtr<nsGenericHTMLElement> > mProperties;
nsTArray<nsRefPtr<nsGenericHTMLElement> > mProperties;
// the itemprop attribute of the properties
nsRefPtr<PropertyStringList> mNames;
// The cached PropertyNodeLists that are NamedItems of this collection
nsRefPtr<PropertyStringList> mNames;
// The cached PropertyNodeLists that are NamedItems of this collection
nsRefPtrHashtable<nsStringHashKey, PropertyNodeList> mNamedItemEntries;
// The element this collection is rooted at
nsCOMPtr<nsGenericHTMLElement> mRoot;
// The document mRoot is in, if any
nsCOMPtr<nsIDocument> 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_

View File

@ -17,6 +17,7 @@ FAIL_ON_WARNINGS = 1
EXPORTS = \
HTMLPropertiesCollection.h \
nsGenericHTMLElement.h \
nsHTMLIFrameElement.h \
nsClientRect.h \

View File

@ -4191,9 +4191,9 @@ nsGenericHTMLElement::Properties()
}
void
nsGenericHTMLElement::GetProperties(nsIDOMHTMLPropertiesCollection** aProperties)
nsGenericHTMLElement::GetProperties(nsISupports** aProperties)
{
NS_ADDREF(*aProperties = Properties());
NS_ADDREF(*aProperties = static_cast<nsIHTMLCollection*>(Properties()));
}
nsSize

View File

@ -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; \

View File

@ -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

View File

@ -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)

View File

@ -62,8 +62,6 @@ SDK_XPIDLSRCS = \
nsIDOMHTMLParagraphElement.idl \
nsIDOMHTMLParamElement.idl \
nsIDOMHTMLPreElement.idl \
nsIDOMHTMLPropertiesCollection.idl \
nsIDOMPropertyNodeList.idl \
nsIDOMHTMLProgressElement.idl \
nsIDOMHTMLQuoteElement.idl \
nsIDOMHTMLScriptElement.idl \

View File

@ -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;

View File

@ -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);
};

View File

@ -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();
};