mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix for bug 801083 (Remove old proxy-based list bindings). r=bz.
This commit is contained in:
parent
6288fe114b
commit
e86cd8818c
@ -74,7 +74,7 @@ nsAccTreeWalker::NextChildInternal(bool aNoWalkUp)
|
||||
mState->childList->GetLength(&length);
|
||||
|
||||
while (mState->childIdx < length) {
|
||||
nsIContent* childNode = mState->childList->GetNodeAt(mState->childIdx);
|
||||
nsIContent* childNode = mState->childList->Item(mState->childIdx);
|
||||
mState->childIdx++;
|
||||
|
||||
bool isSubtreeHidden = false;
|
||||
|
@ -67,7 +67,7 @@ nsXFormsAccessible::GetBoundChildElementValue(const nsAString& aTagName,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (uint32_t index = 0; index < length; index++) {
|
||||
nsIContent* content = nodes->GetNodeAt(index);
|
||||
nsIContent* content = nodes->Item(index);
|
||||
if (content->NodeInfo()->Equals(aTagName) &&
|
||||
content->NodeInfo()->NamespaceEquals(NS_LITERAL_STRING(NS_NAMESPACE_XFORMS))) {
|
||||
nsCOMPtr<nsIDOMNode> DOMNode(do_QueryInterface(content));
|
||||
|
@ -62,6 +62,7 @@ public:
|
||||
|
||||
// nsINodeList interface
|
||||
virtual int32_t IndexOf(nsIContent* aContent);
|
||||
virtual nsIContent* Item(uint32_t aIndex);
|
||||
|
||||
void DropReference()
|
||||
{
|
||||
|
@ -7,10 +7,9 @@
|
||||
|
||||
interface nsIDOMFile;
|
||||
|
||||
[scriptable, uuid(3bfef9fa-8ad3-4e49-bd62-d6cd75b29298)]
|
||||
[scriptable, uuid(283aa7b2-da81-4c72-aea2-9797b440fe34)]
|
||||
interface nsIDOMFileList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long length;
|
||||
[getter,forward(getItemAt)] nsIDOMFile item(in unsigned long index);
|
||||
[noscript,notxpcom,nostdcall] nsIDOMFile getItemAt(in unsigned long index);
|
||||
nsIDOMFile item(in unsigned long index);
|
||||
};
|
||||
|
@ -14,8 +14,8 @@ class nsIContent;
|
||||
|
||||
// IID for the nsINodeList interface
|
||||
#define NS_INODELIST_IID \
|
||||
{ 0xe60b773e, 0x5d20, 0x43f6, \
|
||||
{ 0xb0, 0x8c, 0xfd, 0x65, 0x26, 0xce, 0xe0, 0x7a } }
|
||||
{ 0xadb5e54c, 0x6e96, 0x4102, \
|
||||
{ 0x8d, 0x40, 0xe0, 0x12, 0x3d, 0xcf, 0x48, 0x7a } }
|
||||
|
||||
/**
|
||||
* An internal interface for a reasonably fast indexOf.
|
||||
@ -45,10 +45,7 @@ public:
|
||||
GetLength(&length);
|
||||
return length;
|
||||
}
|
||||
nsIContent* Item(uint32_t aIndex)
|
||||
{
|
||||
return GetNodeAt(aIndex);
|
||||
}
|
||||
virtual nsIContent* Item(uint32_t aIndex) = 0;
|
||||
nsIContent* IndexedGetter(uint32_t aIndex, bool& aFound)
|
||||
{
|
||||
nsIContent* item = Item(aIndex);
|
||||
|
@ -100,7 +100,6 @@
|
||||
#include "nsAsyncDOMEvent.h"
|
||||
#include "nsTextNode.h"
|
||||
#include "mozilla/dom/NodeListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsIXULDocument.h"
|
||||
@ -389,13 +388,7 @@ JSObject*
|
||||
nsChildContentList::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = NodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::NodeList::create(cx, scope, this);
|
||||
return NodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -409,7 +402,7 @@ nsChildContentList::GetLength(uint32_t* aLength)
|
||||
NS_IMETHODIMP
|
||||
nsChildContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsINode* node = GetNodeAt(aIndex);
|
||||
nsINode* node = Item(aIndex);
|
||||
if (!node) {
|
||||
*aReturn = nullptr;
|
||||
|
||||
@ -420,7 +413,7 @@ nsChildContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsChildContentList::GetNodeAt(uint32_t aIndex)
|
||||
nsChildContentList::Item(uint32_t aIndex)
|
||||
{
|
||||
if (mNode) {
|
||||
return mNode->GetChildAt(aIndex);
|
||||
@ -679,7 +672,7 @@ FragmentOrElement::GetChildren(uint32_t aFilter)
|
||||
uint32_t length = 0;
|
||||
childList->GetLength(&length);
|
||||
for (uint32_t idx = 0; idx < length; idx++) {
|
||||
nsIContent* child = childList->GetNodeAt(idx);
|
||||
nsIContent* child = childList->Item(idx);
|
||||
list->AppendElement(child);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "nsGkAtoms.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
#include "mozilla/dom/NodeListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
// Form related includes
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
@ -112,7 +111,7 @@ nsBaseContentList::GetLength(uint32_t* aLength)
|
||||
NS_IMETHODIMP
|
||||
nsBaseContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsISupports *tmp = GetNodeAt(aIndex);
|
||||
nsISupports *tmp = Item(aIndex);
|
||||
|
||||
if (!tmp) {
|
||||
*aReturn = nullptr;
|
||||
@ -124,7 +123,7 @@ nsBaseContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsBaseContentList::GetNodeAt(uint32_t aIndex)
|
||||
nsBaseContentList::Item(uint32_t aIndex)
|
||||
{
|
||||
return mElements.SafeElementAt(aIndex);
|
||||
}
|
||||
@ -163,13 +162,7 @@ JSObject*
|
||||
nsSimpleContentList::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = NodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::NodeList::create(cx, scope, this);
|
||||
return NodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
// nsFormContentList
|
||||
@ -185,7 +178,7 @@ nsFormContentList::nsFormContentList(nsIContent *aForm,
|
||||
aContentList.GetLength(&length);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
nsIContent *c = aContentList.GetNodeAt(i);
|
||||
nsIContent *c = aContentList.Item(i);
|
||||
if (c && nsContentUtils::BelongsInForm(aForm, c)) {
|
||||
AppendElement(c);
|
||||
}
|
||||
@ -303,13 +296,7 @@ JSObject*
|
||||
nsCacheableFuncStringNodeList::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = NodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::NodeList::create(cx, scope, this);
|
||||
return NodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
|
||||
@ -317,13 +304,7 @@ JSObject*
|
||||
nsCacheableFuncStringHTMLCollection::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = HTMLCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::HTMLCollection::create(cx, scope, this);
|
||||
return HTMLCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
// Hashtable for storing nsCacheableFuncStringContentList
|
||||
@ -541,13 +522,7 @@ nsContentList::~nsContentList()
|
||||
JSObject*
|
||||
nsContentList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = HTMLCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::HTMLCollection::create(cx, scope, this);
|
||||
return HTMLCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
DOMCI_DATA(ContentList, nsContentList)
|
||||
@ -662,7 +637,7 @@ nsContentList::GetLength(uint32_t* aLength)
|
||||
NS_IMETHODIMP
|
||||
nsContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsINode* node = GetNodeAt(aIndex);
|
||||
nsINode* node = Item(aIndex);
|
||||
|
||||
if (node) {
|
||||
return CallQueryInterface(node, aReturn);
|
||||
@ -694,19 +669,11 @@ nsContentList::GetElementAt(uint32_t aIndex)
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsContentList::GetNodeAt(uint32_t aIndex)
|
||||
nsContentList::Item(uint32_t aIndex)
|
||||
{
|
||||
return GetElementAt(aIndex);
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
nsContentList::GetNamedItem(const nsAString& aName, nsWrapperCache **aCache)
|
||||
{
|
||||
nsIContent *item;
|
||||
*aCache = item = NamedItem(aName, true);
|
||||
return item;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
nsContentList::NamedItem(JSContext* cx, const nsAString& name,
|
||||
mozilla::ErrorResult& error)
|
||||
|
@ -64,7 +64,8 @@ public:
|
||||
|
||||
// nsINodeList
|
||||
virtual int32_t IndexOf(nsIContent* aContent);
|
||||
|
||||
virtual nsIContent* Item(uint32_t aIndex);
|
||||
|
||||
uint32_t Length() const {
|
||||
return mElements.Length();
|
||||
}
|
||||
@ -273,7 +274,8 @@ public:
|
||||
return mRootNode;
|
||||
}
|
||||
|
||||
virtual nsIContent* GetNodeAt(uint32_t aIndex);
|
||||
virtual nsIContent* Item(uint32_t aIndex);
|
||||
virtual nsGenericElement* GetElementAt(uint32_t index);
|
||||
virtual JSObject* NamedItem(JSContext* cx, const nsAString& name,
|
||||
mozilla::ErrorResult& error);
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "plbase64.h"
|
||||
#include "prmem.h"
|
||||
#include "mozilla/dom/FileListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -709,19 +708,7 @@ JSObject*
|
||||
nsDOMFileList::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = FileListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::FileList::create(cx, scope, this);
|
||||
}
|
||||
|
||||
nsIDOMFile*
|
||||
nsDOMFileList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
return Item(aIndex);
|
||||
return FileListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "nsDOMSettableTokenList.h"
|
||||
#include "mozilla/dom/DOMSettableTokenListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
|
||||
nsDOMSettableTokenList::nsDOMSettableTokenList(nsGenericElement *aElement, nsIAtom* aAttrAtom)
|
||||
@ -52,14 +51,6 @@ JSObject*
|
||||
nsDOMSettableTokenList::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::DOMSettableTokenListBinding::Wrap(cx, scope,
|
||||
this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::DOMSettableTokenList::create(cx, scope,
|
||||
this);
|
||||
return mozilla::dom::DOMSettableTokenListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "nsError.h"
|
||||
#include "nsGenericElement.h"
|
||||
#include "mozilla/dom/DOMTokenListBinding.h"
|
||||
#include "dombindings.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -313,12 +312,6 @@ nsDOMTokenList::ToString(nsAString& aResult)
|
||||
JSObject*
|
||||
nsDOMTokenList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = DOMTokenListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::DOMTokenList::create(cx, scope, this);
|
||||
return DOMTokenListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
|
@ -5139,7 +5139,7 @@ nsDocument::GetAnonymousElementByAttribute(nsIContent* aElement,
|
||||
bool universalMatch = aAttrValue.EqualsLiteral("*");
|
||||
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsIContent* current = nodeList->GetNodeAt(i);
|
||||
nsIContent* current = nodeList->Item(i);
|
||||
nsIContent* matchedElm =
|
||||
GetElementByAttribute(current, aAttrName, aAttrValue, universalMatch);
|
||||
if (matchedElm)
|
||||
@ -8113,7 +8113,7 @@ nsDocument::FindImageMap(const nsAString& aUseMapValue)
|
||||
|
||||
uint32_t i, n = mImageMaps->Length(true);
|
||||
for (i = 0; i < n; ++i) {
|
||||
nsIContent* map = mImageMaps->GetNodeAt(i);
|
||||
nsIContent* map = mImageMaps->Item(i);
|
||||
if (map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::id, mapName,
|
||||
eCaseMatters) ||
|
||||
map->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, mapName,
|
||||
|
@ -71,7 +71,7 @@ nsReferencedElement::Reset(nsIContent* aFromContent, nsIURI* aURI,
|
||||
anonymousChildren->GetLength(&length);
|
||||
for (uint32_t i = 0; i < length && !mElement; ++i) {
|
||||
mElement =
|
||||
nsContentUtils::MatchElementId(anonymousChildren->GetNodeAt(i), ref);
|
||||
nsContentUtils::MatchElementId(anonymousChildren->Item(i), ref);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "nsIFrame.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/PaintRequestListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
DOMCI_DATA(PaintRequest, nsPaintRequest)
|
||||
|
||||
@ -59,15 +58,8 @@ JSObject*
|
||||
nsPaintRequestList::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::PaintRequestListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::PaintRequestList::create(cx, scope,
|
||||
this);
|
||||
return mozilla::dom::PaintRequestListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -83,9 +75,3 @@ nsPaintRequestList::Item(uint32_t aIndex, nsIDOMPaintRequest** aReturn)
|
||||
NS_IF_ADDREF(*aReturn = Item(aIndex));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMPaintRequest*
|
||||
nsPaintRequestList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
return Item(aIndex);
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
struct JSContext;
|
||||
struct JSObject;
|
||||
class nsGenericElement;
|
||||
class nsINode;
|
||||
namespace mozilla {
|
||||
class ErrorResult;
|
||||
@ -18,8 +19,8 @@ class ErrorResult;
|
||||
|
||||
// IID for the nsIHTMLCollection interface
|
||||
#define NS_IHTMLCOLLECTION_IID \
|
||||
{ 0x5c6012c3, 0xa816, 0x4f28, \
|
||||
{ 0xab, 0x93, 0xe9, 0x8a, 0x36, 0x16, 0x88, 0xf2 } }
|
||||
{ 0x5643235d, 0x9a72, 0x4b6a, \
|
||||
{ 0xa6, 0x0c, 0x64, 0x63, 0x72, 0xb7, 0x53, 0x4a } }
|
||||
|
||||
/**
|
||||
* An internal interface
|
||||
@ -43,6 +44,7 @@ public:
|
||||
GetLength(&length);
|
||||
return length;
|
||||
}
|
||||
virtual nsGenericElement* GetElementAt(uint32_t index) = 0;
|
||||
nsGenericElement* Item(uint32_t index)
|
||||
{
|
||||
return GetElementAt(index);
|
||||
|
@ -5,7 +5,6 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "HTMLPropertiesCollection.h"
|
||||
#include "dombindings.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
@ -110,14 +109,7 @@ JSObject*
|
||||
HTMLPropertiesCollection::WrapObject(JSContext* cx, JSObject* scope,
|
||||
bool* triedToWrap)
|
||||
{
|
||||
JSObject* obj = HTMLPropertiesCollectionBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::HTMLPropertiesCollection::create(cx, scope, this);
|
||||
return HTMLPropertiesCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -158,24 +150,6 @@ HTMLPropertiesCollection::NamedItem(JSContext* cx, const nsAString& name,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
HTMLPropertiesCollection::GetNamedItem(const nsAString& aName,
|
||||
nsWrapperCache **aCache)
|
||||
{
|
||||
if (!IsSupportedNamedProperty(aName)) {
|
||||
*aCache = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsRefPtr<PropertyNodeList> propertyList;
|
||||
if (!mNamedItemEntries.Get(aName, getter_AddRefs(propertyList))) {
|
||||
propertyList = new PropertyNodeList(this, mRoot, aName);
|
||||
mNamedItemEntries.Put(aName, propertyList);
|
||||
}
|
||||
*aCache = propertyList;
|
||||
return static_cast<nsIDOMPropertyNodeList*>(propertyList);
|
||||
}
|
||||
|
||||
nsGenericElement*
|
||||
HTMLPropertiesCollection::GetElementAt(uint32_t aIndex)
|
||||
{
|
||||
@ -429,7 +403,7 @@ PropertyNodeList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
PropertyNodeList::GetNodeAt(uint32_t aIndex)
|
||||
PropertyNodeList::Item(uint32_t aIndex)
|
||||
{
|
||||
EnsureFresh();
|
||||
return mElements.SafeElementAt(aIndex);
|
||||
@ -449,16 +423,9 @@ PropertyNodeList::GetParentObject()
|
||||
}
|
||||
|
||||
JSObject*
|
||||
PropertyNodeList::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
PropertyNodeList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = PropertyNodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::PropertyNodeList::create(cx, scope, this);
|
||||
return PropertyNodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(PropertyNodeList)
|
||||
|
@ -59,6 +59,8 @@ public:
|
||||
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap);
|
||||
|
||||
virtual nsGenericElement* GetElementAt(uint32_t aIndex);
|
||||
|
||||
NS_IMETHOD NamedItem(const nsAString& aName, nsIDOMNode** aResult);
|
||||
void SetDocument(nsIDocument* aDocument);
|
||||
nsINode* GetParentObject();
|
||||
@ -141,6 +143,7 @@ public:
|
||||
void GetValues(JSContext* aCx, nsTArray<JS::Value >& aResult,
|
||||
ErrorResult& aError);
|
||||
|
||||
virtual nsIContent* Item(uint32_t aIndex);
|
||||
NS_DECL_NSIDOMPROPERTYNODELIST
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "nsPresContext.h"
|
||||
#include "mozilla/dom/ClientRectListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
DOMCI_DATA(ClientRect, nsClientRect)
|
||||
|
||||
@ -98,23 +97,11 @@ nsClientRectList::Item(uint32_t aIndex, nsIDOMClientRect** aReturn)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMClientRect*
|
||||
nsClientRectList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
return Item(aIndex);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
nsClientRectList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::ClientRectListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::ClientRectList::create(cx, scope, this);
|
||||
return mozilla::dom::ClientRectListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
}
|
||||
|
||||
static double
|
||||
|
@ -99,7 +99,7 @@ nsHTMLFieldSetElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
||||
|
||||
uint32_t length = mElements->Length(true);
|
||||
for (uint32_t i=0; i<length; ++i) {
|
||||
static_cast<nsGenericHTMLFormElement*>(mElements->GetNodeAt(i))
|
||||
static_cast<nsGenericHTMLFormElement*>(mElements->Item(i))
|
||||
->FieldSetDisabledChanged(aNotify);
|
||||
}
|
||||
}
|
||||
@ -230,7 +230,7 @@ nsHTMLFieldSetElement::NotifyElementsForFirstLegendChange(bool aNotify)
|
||||
|
||||
uint32_t length = mElements->Length(true);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
static_cast<nsGenericHTMLFormElement*>(mElements->GetNodeAt(i))
|
||||
static_cast<nsGenericHTMLFormElement*>(mElements->Item(i))
|
||||
->FieldSetFirstLegendChanged(aNotify);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,6 @@
|
||||
|
||||
#include "nsIDOMHTMLButtonElement.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
#include "dombindings.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
@ -93,6 +92,7 @@ public:
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_DECL_NSIDOMHTMLCOLLECTION
|
||||
|
||||
virtual nsGenericElement* GetElementAt(uint32_t index);
|
||||
virtual nsINode* GetParentObject()
|
||||
{
|
||||
return mForm;
|
||||
@ -125,13 +125,7 @@ public:
|
||||
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = HTMLCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::HTMLCollection::create(cx, scope, this);
|
||||
return HTMLCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
nsHTMLFormElement* mForm; // WEAK - the form owns me
|
||||
@ -1948,7 +1942,7 @@ nsHTMLFormElement::GetNextRadioButton(const nsAString& aName,
|
||||
else if (++index >= (int32_t)numRadios) {
|
||||
index = 0;
|
||||
}
|
||||
radio = do_QueryInterface(radioGroup->GetNodeAt(index));
|
||||
radio = do_QueryInterface(radioGroup->Item(index));
|
||||
if (!radio)
|
||||
continue;
|
||||
|
||||
@ -2345,7 +2339,7 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild,
|
||||
// already in the list, since if it tests true the child would
|
||||
// have come at the end of the list, and the PositionIsBefore
|
||||
// will test false.
|
||||
if (nsContentUtils::PositionIsBefore(list->GetNodeAt(list->Length() - 1), aChild)) {
|
||||
if (nsContentUtils::PositionIsBefore(list->Item(list->Length() - 1), aChild)) {
|
||||
list->AppendElement(aChild);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -2366,7 +2360,7 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild,
|
||||
while (last != first) {
|
||||
mid = (first + last) / 2;
|
||||
|
||||
if (nsContentUtils::PositionIsBefore(aChild, list->GetNodeAt(mid)))
|
||||
if (nsContentUtils::PositionIsBefore(aChild, list->Item(mid)))
|
||||
last = mid;
|
||||
else
|
||||
first = mid + 1;
|
||||
@ -2435,7 +2429,7 @@ nsFormControlList::RemoveElementFromTable(nsGenericHTMLFormElement* aChild,
|
||||
} else if (length == 1) {
|
||||
// Only one element left, replace the list in the hash with the
|
||||
// single element.
|
||||
nsIContent* node = list->GetNodeAt(0);
|
||||
nsIContent* node = list->Item(0);
|
||||
if (node) {
|
||||
mNameLookupTable.Put(aName, node);
|
||||
}
|
||||
@ -2529,14 +2523,6 @@ nsFormControlList::GetElementAt(uint32_t aIndex)
|
||||
return mElements.SafeElementAt(aIndex, nullptr);
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
nsFormControlList::GetNamedItem(const nsAString& aName, nsWrapperCache **aCache)
|
||||
{
|
||||
nsISupports *item = NamedItemInternal(aName, true);
|
||||
*aCache = nullptr;
|
||||
return item;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
nsFormControlList::NamedItem(JSContext* cx, const nsAString& name,
|
||||
mozilla::ErrorResult& error)
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "mozilla/dom/HTMLOptionsCollectionBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -2014,13 +2013,7 @@ JSObject*
|
||||
nsHTMLOptionCollection::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = HTMLOptionsCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return oldproxybindings::HTMLOptionsCollection::create(cx, scope, this);
|
||||
return HTMLOptionsCollectionBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -2170,15 +2163,6 @@ GetNamedItemHelper(nsTArray<nsRefPtr<nsHTMLOptionElement> > &aElements,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
nsHTMLOptionCollection::GetNamedItem(const nsAString& aName,
|
||||
nsWrapperCache **aCache)
|
||||
{
|
||||
nsINode *item = GetNamedItemHelper(mElements, aName);
|
||||
*aCache = item;
|
||||
return item;
|
||||
}
|
||||
|
||||
nsINode*
|
||||
nsHTMLOptionCollection::GetParentObject()
|
||||
{
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "nsIHTMLCollection.h"
|
||||
#include "nsHTMLStyleSheet.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -45,6 +44,7 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_NSIDOMHTMLCOLLECTION
|
||||
|
||||
virtual nsGenericElement* GetElementAt(uint32_t aIndex);
|
||||
virtual nsINode* GetParentObject()
|
||||
{
|
||||
return mParent;
|
||||
@ -61,15 +61,8 @@ public:
|
||||
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::HTMLCollectionBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::HTMLCollection::create(cx, scope,
|
||||
this);
|
||||
return mozilla::dom::HTMLCollectionBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -145,7 +138,7 @@ NS_INTERFACE_MAP_END
|
||||
nsContentList *_tbodies = mParent->TBodies(); \
|
||||
nsINode * _node; \
|
||||
uint32_t _tbodyIndex = 0; \
|
||||
_node = _tbodies->GetNodeAt(_tbodyIndex); \
|
||||
_node = _tbodies->Item(_tbodyIndex); \
|
||||
while (_node) { \
|
||||
rowGroup = do_QueryInterface(_node); \
|
||||
if (rowGroup) { \
|
||||
@ -154,7 +147,7 @@ NS_INTERFACE_MAP_END
|
||||
_code \
|
||||
} while (0); \
|
||||
} \
|
||||
_node = _tbodies->GetNodeAt(++_tbodyIndex); \
|
||||
_node = _tbodies->Item(++_tbodyIndex); \
|
||||
} \
|
||||
/* orphan rows */ \
|
||||
rows = mOrphanRows; \
|
||||
@ -250,48 +243,31 @@ TableRowsCollection::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
return CallQueryInterface(node, aReturn);
|
||||
}
|
||||
|
||||
static nsISupports*
|
||||
GetNamedItemInRowGroup(nsIDOMHTMLCollection* aRows, const nsAString& aName,
|
||||
nsWrapperCache** aCache)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLCollection> rows = do_QueryInterface(aRows);
|
||||
if (rows) {
|
||||
return rows->GetNamedItem(aName, aCache);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsISupports*
|
||||
TableRowsCollection::GetNamedItem(const nsAString& aName,
|
||||
nsWrapperCache** aCache)
|
||||
{
|
||||
DO_FOR_EACH_ROWGROUP(
|
||||
nsISupports* item = GetNamedItemInRowGroup(rows, aName, aCache);
|
||||
if (item) {
|
||||
return item;
|
||||
}
|
||||
);
|
||||
*aCache = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
TableRowsCollection::NamedItem(JSContext* cx, const nsAString& name,
|
||||
ErrorResult& error)
|
||||
{
|
||||
nsWrapperCache* cache;
|
||||
DO_FOR_EACH_ROWGROUP(
|
||||
nsISupports* item = GetNamedItemInRowGroup(rows, name, &cache);
|
||||
if (item) {
|
||||
JSObject* wrapper = GetWrapper();
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
JS::Value v;
|
||||
if (!mozilla::dom::WrapObject(cx, wrapper, item, cache, nullptr, &v)) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsIHTMLCollection> collection = do_QueryInterface(rows);
|
||||
if (collection) {
|
||||
// We'd like to call the nsIHTMLCollection::NamedItem that returns a
|
||||
// JSObject*, but that relies on collection having a cached wrapper, which
|
||||
// we can't guarantee here.
|
||||
nsCOMPtr<nsIDOMNode> item;
|
||||
error = collection->NamedItem(name, getter_AddRefs(item));
|
||||
if (error.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
return &v.toObject();
|
||||
if (item) {
|
||||
JSObject* wrapper = GetWrapper();
|
||||
JSAutoCompartment ac(cx, wrapper);
|
||||
JS::Value v;
|
||||
if (!mozilla::dom::WrapObject(cx, wrapper, item, &v)) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
return &v.toObject();
|
||||
}
|
||||
}
|
||||
);
|
||||
return nullptr;
|
||||
@ -301,15 +277,18 @@ NS_IMETHODIMP
|
||||
TableRowsCollection::NamedItem(const nsAString& aName,
|
||||
nsIDOMNode** aReturn)
|
||||
{
|
||||
nsWrapperCache *cache;
|
||||
nsISupports* item = GetNamedItem(aName, &cache);
|
||||
if (!item) {
|
||||
*aReturn = nullptr;
|
||||
DO_FOR_EACH_ROWGROUP(
|
||||
nsCOMPtr<nsIHTMLCollection> collection = do_QueryInterface(rows);
|
||||
if (collection) {
|
||||
nsresult rv = collection->NamedItem(aName, aReturn);
|
||||
if (NS_FAILED(rv) || *aReturn) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return CallQueryInterface(item, aReturn);
|
||||
*aReturn = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -144,11 +144,11 @@ nsHTMLTableRowElement::GetRowIndex(int32_t* aValue)
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
table->GetRows(getter_AddRefs(rows));
|
||||
|
||||
uint32_t numRows;
|
||||
rows->GetLength(&numRows);
|
||||
nsCOMPtr<nsIHTMLCollection> coll = do_QueryInterface(rows);
|
||||
uint32_t numRows = coll->Length();
|
||||
|
||||
for (uint32_t i = 0; i < numRows; i++) {
|
||||
if (rows->GetElementAt(i) == this) {
|
||||
if (coll->GetElementAt(i) == this) {
|
||||
*aValue = i;
|
||||
break;
|
||||
}
|
||||
@ -168,10 +168,10 @@ nsHTMLTableRowElement::GetSectionRowIndex(int32_t* aValue)
|
||||
nsCOMPtr<nsIDOMHTMLCollection> rows;
|
||||
section->GetRows(getter_AddRefs(rows));
|
||||
|
||||
uint32_t numRows;
|
||||
rows->GetLength(&numRows);
|
||||
nsCOMPtr<nsIHTMLCollection> coll = do_QueryInterface(rows);
|
||||
uint32_t numRows = coll->Length();
|
||||
for (uint32_t i = 0; i < numRows; i++) {
|
||||
if (rows->GetElementAt(i) == this) {
|
||||
if (coll->GetElementAt(i) == this) {
|
||||
*aValue = i;
|
||||
break;
|
||||
}
|
||||
|
@ -1040,7 +1040,7 @@ nsHTMLDocument::GetBody()
|
||||
nsRefPtr<nsContentList> nodeList =
|
||||
NS_GetContentList(this, kNameSpaceID_XHTML, NS_LITERAL_STRING("frameset"));
|
||||
|
||||
return nodeList->GetNodeAt(0);
|
||||
return nodeList->Item(0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -2096,7 +2096,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
|
||||
// Only one element in the list, return the element instead of
|
||||
// returning the list
|
||||
|
||||
nsIContent *node = list->GetNodeAt(0);
|
||||
nsIContent *node = list->Item(0);
|
||||
if (!aForm || nsContentUtils::BelongsInForm(aForm, node)) {
|
||||
NS_ADDREF(*aResult = node);
|
||||
*aCache = node;
|
||||
@ -2124,7 +2124,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
|
||||
// nothing or one element in the list. Return that element, or null
|
||||
// if there's no element in the list.
|
||||
|
||||
nsIContent *node = fc_list->GetNodeAt(0);
|
||||
nsIContent *node = fc_list->Item(0);
|
||||
|
||||
NS_IF_ADDREF(*aResult = node);
|
||||
*aCache = node;
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/SVGLengthListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
// See the comment in this file's header.
|
||||
|
||||
@ -77,21 +76,7 @@ NS_INTERFACE_MAP_END
|
||||
JSObject*
|
||||
DOMSVGLengthList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::SVGLengthListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::SVGLengthList::create(cx, scope, this);
|
||||
}
|
||||
|
||||
nsIDOMSVGLength*
|
||||
DOMSVGLengthList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
return GetItem(aIndex, rv);
|
||||
return mozilla::dom::SVGLengthListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/SVGNumberListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
// See the comment in this file's header.
|
||||
|
||||
@ -78,21 +77,7 @@ NS_INTERFACE_MAP_END
|
||||
JSObject*
|
||||
DOMSVGNumberList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::SVGNumberListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::SVGNumberList::create(cx, scope, this);
|
||||
}
|
||||
|
||||
nsIDOMSVGNumber*
|
||||
DOMSVGNumberList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
return GetItem(aIndex, rv);
|
||||
return mozilla::dom::SVGNumberListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
#include "SVGPathSegUtils.h"
|
||||
#include "mozilla/dom/SVGPathSegListBinding.h"
|
||||
#include "dombindings.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
// See the comment in this file's header.
|
||||
@ -84,22 +83,8 @@ DOMSVGPathSegList::~DOMSVGPathSegList()
|
||||
JSObject*
|
||||
DOMSVGPathSegList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::SVGPathSegListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::SVGPathSegList::create(cx, scope,
|
||||
this);
|
||||
}
|
||||
|
||||
nsIDOMSVGPathSeg*
|
||||
DOMSVGPathSegList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
return GetItem(aIndex, rv);
|
||||
return mozilla::dom::SVGPathSegListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsSVGAttrTearoffTable.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/SVGPointListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
// See the comment in this file's header.
|
||||
|
||||
@ -103,27 +102,7 @@ DOMSVGPointList::~DOMSVGPointList()
|
||||
JSObject*
|
||||
DOMSVGPointList::WrapObject(JSContext *cx, JSObject *scope, bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::SVGPointListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::SVGPointList::create(cx, scope, this);
|
||||
}
|
||||
|
||||
nsIDOMSVGPoint*
|
||||
DOMSVGPointList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
if (IsAnimValList()) {
|
||||
Element()->FlushAnimations();
|
||||
}
|
||||
if (aIndex < LengthNoFlush()) {
|
||||
EnsureItemAt(aIndex);
|
||||
return mItems[aIndex];
|
||||
}
|
||||
return nullptr;
|
||||
return mozilla::dom::SVGPointListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/dom/SVGTransformListBinding.h"
|
||||
#include "dombindings.h"
|
||||
#include "nsError.h"
|
||||
|
||||
// local helper functions
|
||||
@ -78,22 +77,8 @@ JSObject*
|
||||
DOMSVGTransformList::WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::SVGTransformListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::SVGTransformList::create(cx, scope,
|
||||
this);
|
||||
}
|
||||
|
||||
nsIDOMSVGTransform*
|
||||
DOMSVGTransformList::GetItemAt(uint32_t aIndex)
|
||||
{
|
||||
ErrorResult rv;
|
||||
return GetItem(aIndex, rv);
|
||||
return mozilla::dom::SVGTransformListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -44,7 +44,6 @@
|
||||
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/dom/NodeListBinding.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
// ==================================================================
|
||||
// = nsAnonymousContentList
|
||||
@ -71,6 +70,7 @@ public:
|
||||
{
|
||||
return mContent;
|
||||
}
|
||||
virtual nsIContent* Item(uint32_t aIndex);
|
||||
|
||||
int32_t GetInsertionPointCount() { return mElements->Length(); }
|
||||
|
||||
@ -80,14 +80,7 @@ public:
|
||||
virtual JSObject* WrapObject(JSContext *cx, JSObject *scope,
|
||||
bool *triedToWrap)
|
||||
{
|
||||
JSObject* obj = mozilla::dom::NodeListBinding::Wrap(cx, scope, this,
|
||||
triedToWrap);
|
||||
if (obj || *triedToWrap) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
*triedToWrap = true;
|
||||
return mozilla::dom::oldproxybindings::NodeList::create(cx, scope, this);
|
||||
return mozilla::dom::NodeListBinding::Wrap(cx, scope, this, triedToWrap);
|
||||
}
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ANONYMOUS_CONTENT_LIST_IID)
|
||||
@ -174,7 +167,7 @@ nsAnonymousContentList::GetLength(uint32_t* aLength)
|
||||
NS_IMETHODIMP
|
||||
nsAnonymousContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
nsINode* item = GetNodeAt(aIndex);
|
||||
nsINode* item = Item(aIndex);
|
||||
if (!item)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -182,7 +175,7 @@ nsAnonymousContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsAnonymousContentList::GetNodeAt(uint32_t aIndex)
|
||||
nsAnonymousContentList::Item(uint32_t aIndex)
|
||||
{
|
||||
int32_t cnt = mElements->Length();
|
||||
uint32_t pointCount = 0;
|
||||
|
@ -487,7 +487,6 @@ using mozilla::dom::indexedDB::IDBWrapperCache;
|
||||
#include "nsDOMMutationObserver.h"
|
||||
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
#include "dombindings.h"
|
||||
#include "mozilla/dom/HTMLCollectionBinding.h"
|
||||
|
||||
#include "nsIDOMBatteryManager.h"
|
||||
@ -4537,13 +4536,9 @@ nsDOMClassInfo::Init()
|
||||
sDisableGlobalScopePollutionSupport =
|
||||
Preferences::GetBool("browser.dom.global_scope_pollution.disabled");
|
||||
|
||||
// Non-proxy bindings
|
||||
// Register new DOM bindings
|
||||
mozilla::dom::Register(nameSpaceManager);
|
||||
|
||||
// This needs to happen after the call to mozilla::dom::Register, because we
|
||||
// overwrite some values.
|
||||
mozilla::dom::oldproxybindings::Register(nameSpaceManager);
|
||||
|
||||
sIsInitialized = true;
|
||||
|
||||
return NS_OK;
|
||||
@ -8917,7 +8912,7 @@ nsHTMLDocumentSH::DocumentAllGetProperty(JSContext *cx, JSHandleObject obj_,
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsIContent *node = nodeList->GetNodeAt(JSID_TO_INT(id));
|
||||
nsIContent *node = nodeList->Item(JSID_TO_INT(id));
|
||||
|
||||
result = node;
|
||||
cache = node;
|
||||
|
@ -324,7 +324,7 @@ nsFocusManager::GetRedirectedFocus(nsIContent* aContent)
|
||||
|
||||
nsINodeList* children = doc->BindingManager()->GetXBLChildNodesFor(aContent);
|
||||
if (children) {
|
||||
nsIContent* child = children->GetNodeAt(0);
|
||||
nsIContent* child = children->Item(0);
|
||||
if (child && child->Tag() == nsGkAtoms::slider)
|
||||
return child;
|
||||
}
|
||||
|
@ -100,10 +100,7 @@ UnwrapDOMObject(JSObject* obj, DOMObjectSlot slot)
|
||||
if (IsDOMClass(js::GetObjectClass(obj))) {
|
||||
MOZ_ASSERT(slot == eRegularDOMObject);
|
||||
} else {
|
||||
MOZ_ASSERT(js::IsObjectProxyClass(js::GetObjectClass(obj)) ||
|
||||
js::IsFunctionProxyClass(js::GetObjectClass(obj)));
|
||||
MOZ_ASSERT(js::GetProxyHandler(obj)->family() == ProxyFamily());
|
||||
MOZ_ASSERT(IsNewProxyBinding(js::GetProxyHandler(obj)));
|
||||
MOZ_ASSERT(IsDOMProxy(obj));
|
||||
MOZ_ASSERT(slot == eProxyDOMObject);
|
||||
}
|
||||
#endif
|
||||
@ -129,9 +126,8 @@ GetDOMClass(JSObject* obj)
|
||||
return &DOMJSClass::FromJSClass(clasp)->mClass;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(IsDOMProxy(obj));
|
||||
js::BaseProxyHandler* handler = js::GetProxyHandler(obj);
|
||||
MOZ_ASSERT(handler->family() == ProxyFamily());
|
||||
MOZ_ASSERT(IsNewProxyBinding(handler));
|
||||
return &static_cast<DOMProxyHandler*>(handler)->mClass;
|
||||
}
|
||||
|
||||
@ -146,7 +142,7 @@ GetDOMClass(JSObject* obj, const DOMClass*& result)
|
||||
|
||||
if (js::IsObjectProxyClass(clasp) || js::IsFunctionProxyClass(clasp)) {
|
||||
js::BaseProxyHandler* handler = js::GetProxyHandler(obj);
|
||||
if (handler->family() == ProxyFamily() && IsNewProxyBinding(handler)) {
|
||||
if (handler->family() == ProxyFamily()) {
|
||||
result = &static_cast<DOMProxyHandler*>(handler)->mClass;
|
||||
return eProxyDOMObject;
|
||||
}
|
||||
@ -174,8 +170,7 @@ IsDOMObject(JSObject* obj)
|
||||
js::Class* clasp = js::GetObjectClass(obj);
|
||||
return IsDOMClass(clasp) ||
|
||||
((js::IsObjectProxyClass(clasp) || js::IsFunctionProxyClass(clasp)) &&
|
||||
(js::GetProxyHandler(obj)->family() == ProxyFamily() &&
|
||||
IsNewProxyBinding(js::GetProxyHandler(obj))));
|
||||
js::GetProxyHandler(obj)->family() == ProxyFamily());
|
||||
}
|
||||
|
||||
// Some callers don't want to set an exception when unwrapping fails
|
||||
|
@ -125,18 +125,15 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'nsClientRectList',
|
||||
'headerFile': 'nsClientRect.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
}],
|
||||
|
||||
'CSS2Properties': {
|
||||
'nativeType': 'nsDOMCSSDeclaration',
|
||||
'prefable': True,
|
||||
'nativeType': 'nsDOMCSSDeclaration'
|
||||
},
|
||||
|
||||
'CSSStyleDeclaration': {
|
||||
'nativeType': 'nsICSSDeclaration',
|
||||
'prefable': True
|
||||
'nativeType': 'nsICSSDeclaration'
|
||||
},
|
||||
|
||||
'Document': [
|
||||
@ -150,7 +147,6 @@ DOMInterfaces = {
|
||||
'DOMSettableTokenList': [
|
||||
{
|
||||
'nativeType': 'nsDOMSettableTokenList',
|
||||
'prefable': True,
|
||||
'binaryNames': {
|
||||
'__stringifier': 'Stringify'
|
||||
}
|
||||
@ -159,7 +155,6 @@ DOMInterfaces = {
|
||||
'DOMTokenList': [
|
||||
{
|
||||
'nativeType': 'nsDOMTokenList',
|
||||
'prefable': True,
|
||||
'binaryNames': {
|
||||
'__stringifier': 'Stringify'
|
||||
}
|
||||
@ -191,7 +186,6 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'nsDOMFileList',
|
||||
'headerFile': 'nsDOMFile.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
}],
|
||||
|
||||
@ -207,7 +201,6 @@ DOMInterfaces = {
|
||||
'HTMLCollection': [
|
||||
{
|
||||
'nativeType': 'nsIHTMLCollection',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
}],
|
||||
|
||||
@ -215,7 +208,6 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'nsHTMLOptionCollection',
|
||||
'headerFile': 'nsHTMLSelectElement.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'item' ],
|
||||
'binaryNames': {
|
||||
'__indexedsettercreator': 'SetOption'
|
||||
@ -225,7 +217,6 @@ DOMInterfaces = {
|
||||
'HTMLPropertiesCollection': [
|
||||
{
|
||||
'headerFile': 'HTMLPropertiesCollection.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'item', 'namedItem', 'names' ]
|
||||
}],
|
||||
|
||||
@ -267,7 +258,6 @@ DOMInterfaces = {
|
||||
'NodeList': [
|
||||
{
|
||||
'nativeType': 'nsINodeList',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
}],
|
||||
|
||||
@ -275,7 +265,6 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'nsPaintRequestList',
|
||||
'headerFile': 'nsPaintRequest.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
}],
|
||||
|
||||
@ -297,7 +286,6 @@ DOMInterfaces = {
|
||||
'PropertyNodeList': [
|
||||
{
|
||||
'headerFile': 'HTMLPropertiesCollection.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'item' ]
|
||||
}],
|
||||
|
||||
@ -310,7 +298,6 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'mozilla::DOMSVGLengthList',
|
||||
'headerFile': 'DOMSVGLengthList.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'getItem' ]
|
||||
}],
|
||||
|
||||
@ -318,7 +305,6 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'mozilla::DOMSVGNumberList',
|
||||
'headerFile': 'DOMSVGNumberList.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'getItem' ]
|
||||
}],
|
||||
|
||||
@ -326,7 +312,6 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'mozilla::DOMSVGPathSegList',
|
||||
'headerFile': 'DOMSVGPathSegList.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'getItem' ]
|
||||
}],
|
||||
|
||||
@ -334,7 +319,6 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'mozilla::DOMSVGPointList',
|
||||
'headerFile': 'DOMSVGPointList.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'getItem' ]
|
||||
}],
|
||||
|
||||
@ -342,7 +326,6 @@ DOMInterfaces = {
|
||||
{
|
||||
'nativeType': 'mozilla::DOMSVGTransformList',
|
||||
'headerFile': 'DOMSVGTransformList.h',
|
||||
'prefable': True,
|
||||
'resultNotAddRefed': [ 'getItem' ]
|
||||
}],
|
||||
|
||||
@ -456,6 +439,12 @@ DOMInterfaces = {
|
||||
'wrapperCache': False
|
||||
},
|
||||
|
||||
'WebSocket': [
|
||||
{
|
||||
'headerFile': 'WebSocket.h',
|
||||
'implicitJSContext': [ 'constructor' ]
|
||||
}],
|
||||
|
||||
'XMLHttpRequest': [
|
||||
{
|
||||
'nativeType': 'nsXMLHttpRequest',
|
||||
@ -488,12 +477,6 @@ DOMInterfaces = {
|
||||
'workers': True,
|
||||
}],
|
||||
|
||||
'WebSocket': [
|
||||
{
|
||||
'headerFile': 'WebSocket.h',
|
||||
'implicitJSContext': [ 'constructor' ]
|
||||
}],
|
||||
|
||||
####################################
|
||||
# Test Interfaces of various sorts #
|
||||
####################################
|
||||
|
@ -25,11 +25,11 @@ enum {
|
||||
|
||||
template<typename T> struct Prefable;
|
||||
|
||||
class DOMProxyHandler : public DOMBaseProxyHandler
|
||||
class DOMProxyHandler : public js::BaseProxyHandler
|
||||
{
|
||||
public:
|
||||
DOMProxyHandler(const DOMClass& aClass)
|
||||
: DOMBaseProxyHandler(true),
|
||||
: js::BaseProxyHandler(ProxyFamily()),
|
||||
mClass(aClass)
|
||||
{
|
||||
}
|
||||
|
@ -5,10 +5,9 @@
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(917da19d-62f5-441d-b47e-9e35f05639c9)]
|
||||
[scriptable, uuid(f474c567-cbcb-458f-abad-ae42363da287)]
|
||||
interface nsIDOMClientRectList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long length;
|
||||
[getter,forward(getItemAt)] nsIDOMClientRect item(in unsigned long index);
|
||||
[noscript,notxpcom,nostdcall] nsIDOMClientRect getItemAt(in unsigned long index);
|
||||
nsIDOMClientRect item(in unsigned long index);
|
||||
};
|
||||
|
@ -17,11 +17,11 @@ interface nsIDOMDOMTokenList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long length;
|
||||
|
||||
[getter,binaryname(MozItem)] DOMString item(in unsigned long index);
|
||||
[binaryname(MozItem)] DOMString item(in unsigned long index);
|
||||
boolean contains([Null(Stringify)] in DOMString token);
|
||||
void add([Null(Stringify)] in DOMString token);
|
||||
void remove([Null(Stringify)] in DOMString token);
|
||||
boolean toggle([Null(Stringify)] in DOMString token);
|
||||
|
||||
[stringifier] DOMString toString();
|
||||
DOMString toString();
|
||||
};
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIContent;
|
||||
|
||||
/**
|
||||
* The nsIDOMNodeList interface provides the abstraction of an ordered
|
||||
* collection of nodes, without defining or constraining how this collection
|
||||
@ -17,14 +15,9 @@ interface nsIContent;
|
||||
* http://www.w3.org/TR/DOM-Level-2-Core/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(496852ba-e48d-4fa5-982e-e0dc1b475bf1)]
|
||||
[scriptable, uuid(450cf0ba-de90-4f86-85bf-e10cc8b8713f)]
|
||||
interface nsIDOMNodeList : nsISupports
|
||||
{
|
||||
[getter,forward(getNodeAt)] nsIDOMNode item(in unsigned long index);
|
||||
nsIDOMNode item(in unsigned long index);
|
||||
readonly attribute unsigned long length;
|
||||
|
||||
/**
|
||||
* Get the node at the index. Returns null if the index is out of bounds
|
||||
*/
|
||||
[noscript,notxpcom,nostdcall] nsIContent getNodeAt(in unsigned long index);
|
||||
};
|
||||
|
@ -7,10 +7,9 @@
|
||||
|
||||
interface nsIDOMPaintRequest;
|
||||
|
||||
[scriptable, uuid(01627136-fdd8-44b4-aac0-7d613608a3d4)]
|
||||
[scriptable, uuid(1d6a6e10-e9f0-468b-b8e5-da39c945690e)]
|
||||
interface nsIDOMPaintRequestList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long length;
|
||||
[getter,forward(getItemAt)] nsIDOMPaintRequest item(in unsigned long index);
|
||||
[noscript,notxpcom,nostdcall] nsIDOMPaintRequest getItemAt(in unsigned long index);
|
||||
nsIDOMPaintRequest item(in unsigned long index);
|
||||
};
|
||||
|
@ -5,8 +5,6 @@
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsGenericElement;
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLCollection interface is an interface to a collection
|
||||
* of [X]HTML elements.
|
||||
@ -18,22 +16,11 @@ interface nsGenericElement;
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/
|
||||
*/
|
||||
|
||||
[scriptable, uuid(db690d8f-3bca-4198-be64-78adb7f38bf8)]
|
||||
[scriptable, uuid(bb07f567-5b37-4172-92aa-7d00ceed4809)]
|
||||
interface nsIDOMHTMLCollection : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long length;
|
||||
|
||||
[getter,forward(getElementAt)] nsIDOMNode item(in unsigned long index);
|
||||
[getter,forward(getNamedItem)] nsIDOMNode namedItem(in DOMString name);
|
||||
|
||||
/**
|
||||
* Get the node at the index. Returns null if the index is out of bounds.
|
||||
*/
|
||||
[noscript,notxpcom,nostdcall] nsGenericElement getElementAt(in unsigned long index);
|
||||
|
||||
/**
|
||||
* Get the node for the name. Returns null if no node exists for the name.
|
||||
*/
|
||||
[noscript,notxpcom,nostdcall] nsISupports getNamedItem(in DOMString name,
|
||||
out nsWrapperCachePtr cache);
|
||||
nsIDOMNode item(in unsigned long index);
|
||||
nsIDOMNode namedItem(in DOMString name);
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ interface nsIDOMHTMLSelectElement;
|
||||
*/
|
||||
|
||||
// Introduced in DOM Level 2:
|
||||
[scriptable, uuid(429b041b-06df-486c-9a3a-a1d901cc76a2)]
|
||||
[scriptable, uuid(4173cc53-30f6-4d12-a770-981ba53164e2)]
|
||||
interface nsIDOMHTMLOptionsCollection : nsISupports
|
||||
{
|
||||
attribute unsigned long length;
|
||||
@ -32,18 +32,12 @@ interface nsIDOMHTMLOptionsCollection : nsISupports
|
||||
|
||||
// FIXME namedItem (and getNamedItem) should return a NodeList if there are
|
||||
// multiple matching items
|
||||
[getter,forward(getNamedItem)] nsIDOMNode namedItem(in DOMString name);
|
||||
|
||||
/**
|
||||
* Get the node for the name. Returns null if no node exists for the name.
|
||||
*/
|
||||
[noscript,notxpcom,nostdcall] nsISupports getNamedItem(in DOMString name,
|
||||
out nsWrapperCachePtr cache);
|
||||
nsIDOMNode namedItem(in DOMString name);
|
||||
|
||||
attribute long selectedIndex;
|
||||
|
||||
[setter,noscript] void setOption(in unsigned long index,
|
||||
in nsIDOMHTMLOptionElement option);
|
||||
[noscript] void setOption(in unsigned long index,
|
||||
in nsIDOMHTMLOptionElement option);
|
||||
|
||||
[noscript] readonly attribute nsIDOMHTMLSelectElement select;
|
||||
|
||||
|
@ -4,31 +4,17 @@
|
||||
* 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 "nsIDOMHTMLElement.idl"
|
||||
#include "nsIDOMPropertyNodeList.idl"
|
||||
#include "nsIDOMDOMStringList.idl"
|
||||
|
||||
interface nsGenericElement;
|
||||
|
||||
// This interface should extend nsIDOMHTMLCollection, which will be fixed when
|
||||
// it is converted to webidl.
|
||||
[scriptable, uuid(b7e84688-98e0-46b2-9d20-8a0e7329dd25)]
|
||||
[scriptable, uuid(b3a368e4-61a4-4578-94ce-57f98b0e79e8)]
|
||||
interface nsIDOMHTMLPropertiesCollection : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long length;
|
||||
readonly attribute nsIDOMDOMStringList names;
|
||||
|
||||
[getter,forward(getElementAt)] nsIDOMNode item(in unsigned long index);
|
||||
nsIDOMNode item(in unsigned long index);
|
||||
nsIDOMPropertyNodeList namedItem(in DOMString name);
|
||||
|
||||
/**
|
||||
* Get the node at the index. Returns null if the index is out of bounds.
|
||||
*/
|
||||
[noscript,notxpcom,nostdcall] nsGenericElement getElementAt(in unsigned long index);
|
||||
|
||||
/**
|
||||
* Get the node for the name. Returns null if no node exists for the name.
|
||||
*/
|
||||
[noscript,notxpcom,nostdcall] nsISupports getNamedItem(in DOMString name,
|
||||
out nsWrapperCachePtr cache);
|
||||
};
|
||||
|
@ -7,17 +7,10 @@
|
||||
#include "nsIVariant.idl"
|
||||
|
||||
interface nsIDOMNode;
|
||||
interface nsIContent;
|
||||
|
||||
[scriptable, uuid(255cc828-49e8-4fb0-8e36-875e6e072da3)]
|
||||
[scriptable, uuid(22c9c591-182d-4504-8a95-d3274a8b147a)]
|
||||
interface nsIDOMPropertyNodeList : nsISupports {
|
||||
[getter,forward(getNodeAt)] nsIDOMNode item(in unsigned long index);
|
||||
nsIDOMNode item(in unsigned long index);
|
||||
readonly attribute unsigned long length;
|
||||
|
||||
/**
|
||||
* Get the node at the index. Returns null if the index is out of bounds
|
||||
*/
|
||||
[noscript,notxpcom,nostdcall] nsIContent getNodeAt(in unsigned long index);
|
||||
|
||||
nsIVariant getValues();
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
interface nsIDOMSVGLength;
|
||||
|
||||
[scriptable, uuid(f8c89734-d6b4-4a56-bdf5-1ce1104dc1ab)]
|
||||
[scriptable, uuid(ff34ad88-3465-4559-853d-7fdd5bf5e5e9)]
|
||||
interface nsIDOMSVGLengthList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long numberOfItems;
|
||||
@ -19,7 +19,6 @@ interface nsIDOMSVGLengthList : nsISupports
|
||||
// raises(nsIDOMDOMException, nsIDOMSVGException);
|
||||
nsIDOMSVGLength getItem(in unsigned long index);
|
||||
// raises(nsIDOMDOMException);
|
||||
[getter,noscript,notxpcom,nostdcall] nsIDOMSVGLength getItemAt(in unsigned long index);
|
||||
nsIDOMSVGLength insertItemBefore(in nsIDOMSVGLength newItem, in unsigned long index);
|
||||
// raises(nsIDOMDOMException, nsIDOMSVGException);
|
||||
nsIDOMSVGLength replaceItem(in nsIDOMSVGLength newItem, in unsigned long index);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
interface nsIDOMSVGNumber;
|
||||
|
||||
[scriptable, uuid(8e303812-38b4-4780-9f8c-9ddbfcb26c81)]
|
||||
[scriptable, uuid(35d7c850-b2c7-41e4-be59-08f6b29aa78f)]
|
||||
interface nsIDOMSVGNumberList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long numberOfItems;
|
||||
@ -19,7 +19,6 @@ interface nsIDOMSVGNumberList : nsISupports
|
||||
// raises(nsIDOMDOMException, nsIDOMSVGException);
|
||||
nsIDOMSVGNumber getItem(in unsigned long index);
|
||||
// raises(nsIDOMDOMException);
|
||||
[getter,noscript,notxpcom,nostdcall] nsIDOMSVGNumber getItemAt(in unsigned long index);
|
||||
nsIDOMSVGNumber insertItemBefore(in nsIDOMSVGNumber newItem, in unsigned long index);
|
||||
// raises(nsIDOMDOMException, nsIDOMSVGException);
|
||||
nsIDOMSVGNumber replaceItem(in nsIDOMSVGNumber newItem, in unsigned long index);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
interface nsIDOMSVGPathSeg;
|
||||
|
||||
[scriptable, uuid(1e4efb5c-7b0f-4338-a92e-6ca5402b303c)]
|
||||
[scriptable, uuid(24bc0498-ebfd-4966-a1c7-524e939308c9)]
|
||||
interface nsIDOMSVGPathSegList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long numberOfItems;
|
||||
@ -19,7 +19,6 @@ interface nsIDOMSVGPathSegList : nsISupports
|
||||
// raises(nsIDOMDOMException, nsIDOMSVGException);
|
||||
nsIDOMSVGPathSeg getItem(in unsigned long index);
|
||||
// raises(nsIDOMDOMException);
|
||||
[getter,noscript,notxpcom,nostdcall] nsIDOMSVGPathSeg getItemAt(in unsigned long index);
|
||||
nsIDOMSVGPathSeg insertItemBefore(in nsIDOMSVGPathSeg newItem, in unsigned long index);
|
||||
// raises(nsIDOMDOMException, nsIDOMSVGException);
|
||||
nsIDOMSVGPathSeg replaceItem(in nsIDOMSVGPathSeg newItem, in unsigned long index);
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
interface nsIDOMSVGPoint;
|
||||
|
||||
[scriptable, uuid(7bb28750-7238-4083-b5f4-4def4646a637)]
|
||||
[scriptable, uuid(1cc66e7d-c874-4429-9f73-a0e5f2c77a85)]
|
||||
interface nsIDOMSVGPointList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long numberOfItems;
|
||||
@ -19,7 +19,6 @@ interface nsIDOMSVGPointList : nsISupports
|
||||
// raises( DOMException, SVGException );
|
||||
nsIDOMSVGPoint getItem (in unsigned long index);
|
||||
// raises( DOMException );
|
||||
[getter,noscript,notxpcom,nostdcall] nsIDOMSVGPoint getItemAt(in unsigned long index);
|
||||
nsIDOMSVGPoint insertItemBefore(in nsIDOMSVGPoint newItem, in unsigned long index);
|
||||
// raises( DOMException, SVGException );
|
||||
nsIDOMSVGPoint replaceItem(in nsIDOMSVGPoint newItem, in unsigned long index);
|
||||
|
@ -8,7 +8,7 @@
|
||||
interface nsIDOMSVGTransform;
|
||||
interface nsIDOMSVGMatrix;
|
||||
|
||||
[scriptable, uuid(6302eb5d-25d5-4df6-ab8b-e57e37c1a48d)]
|
||||
[scriptable, uuid(e6ea8113-ccd8-4084-a15f-07ca7db1d3fe)]
|
||||
interface nsIDOMSVGTransformList : nsISupports
|
||||
{
|
||||
readonly attribute unsigned long numberOfItems;
|
||||
@ -20,7 +20,6 @@ interface nsIDOMSVGTransformList : nsISupports
|
||||
// raises( DOMException, SVGException );
|
||||
nsIDOMSVGTransform getItem(in unsigned long index);
|
||||
// raises( DOMException );
|
||||
[getter,noscript,notxpcom,nostdcall] nsIDOMSVGTransform getItemAt(in unsigned long index);
|
||||
nsIDOMSVGTransform insertItemBefore(in nsIDOMSVGTransform newItem,
|
||||
in unsigned long index);
|
||||
// raises( DOMException, SVGException );
|
||||
|
@ -260,17 +260,19 @@ nsPlaintextEditor::UpdateMetaCharset(nsIDOMDocument* aDocument,
|
||||
{
|
||||
MOZ_ASSERT(aDocument);
|
||||
// get a list of META tags
|
||||
nsCOMPtr<nsIDOMNodeList> metaList;
|
||||
nsCOMPtr<nsIDOMNodeList> list;
|
||||
nsresult rv = aDocument->GetElementsByTagName(NS_LITERAL_STRING("meta"),
|
||||
getter_AddRefs(metaList));
|
||||
getter_AddRefs(list));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
NS_ENSURE_TRUE(metaList, false);
|
||||
NS_ENSURE_TRUE(list, false);
|
||||
|
||||
nsCOMPtr<nsINodeList> metaList = do_QueryInterface(list);
|
||||
|
||||
uint32_t listLength = 0;
|
||||
metaList->GetLength(&listLength);
|
||||
|
||||
for (uint32_t i = 0; i < listLength; ++i) {
|
||||
nsCOMPtr<nsIContent> metaNode = metaList->GetNodeAt(i);
|
||||
nsCOMPtr<nsIContent> metaNode = metaList->Item(i);
|
||||
MOZ_ASSERT(metaNode);
|
||||
|
||||
if (!metaNode->IsElement()) {
|
||||
|
@ -20,8 +20,6 @@ EXPORTS = \
|
||||
xpcObjectHelper.h \
|
||||
xpcpublic.h \
|
||||
XPCJSMemoryReporter.h \
|
||||
dombindings.h \
|
||||
dombindings_gen.h \
|
||||
GeneratedEvents.h
|
||||
|
||||
CPPSRCS = \
|
||||
@ -56,7 +54,6 @@ CPPSRCS = \
|
||||
XPCWrapper.cpp \
|
||||
XPCQuickStubs.cpp \
|
||||
dom_quickstubs.cpp \
|
||||
dombindings.cpp \
|
||||
DictionaryHelpers.cpp \
|
||||
GeneratedEvents.cpp \
|
||||
$(NULL)
|
||||
@ -83,7 +80,7 @@ SHARED_LIBRARY_LIBS = \
|
||||
../wrappers/$(LIB_PREFIX)xpcwrappers_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_MDDEPEND_FILES = dom_qsgen.pp dombindingsgen.pp dictionary_helper_gen.pp event_impl_gen.pp
|
||||
EXTRA_MDDEPEND_FILES = dom_qsgen.pp dictionary_helper_gen.pp event_impl_gen.pp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@ -119,38 +116,6 @@ dom_quickstubs.cpp: $(srcdir)/dom_quickstubs.qsconf \
|
||||
$(ENABLE_TRACEABLE_FLAGS) \
|
||||
$(srcdir)/dom_quickstubs.qsconf
|
||||
|
||||
dombindings.$(OBJ_SUFFIX): dombindings_gen.h \
|
||||
dombindings_gen.cpp
|
||||
|
||||
dombindings_gen.h: $(srcdir)/dombindings.conf \
|
||||
$(srcdir)/dombindingsgen.py \
|
||||
$(srcdir)/codegen.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/header.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/xpidl.py \
|
||||
$(DEPTH)/js/src/js-confdefs.h
|
||||
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
|
||||
$(PLY_INCLUDE) \
|
||||
-I$(LIBXUL_DIST)/sdk/bin \
|
||||
$(srcdir)/dombindingsgen.py \
|
||||
--idlpath=$(DEPTH)/dist/idl \
|
||||
--header-output dombindings_gen.h \
|
||||
$(srcdir)/dombindings.conf
|
||||
|
||||
dombindings_gen.cpp: $(srcdir)/dombindings.conf \
|
||||
$(srcdir)/dombindingsgen.py \
|
||||
$(srcdir)/codegen.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/header.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/xpidl.py \
|
||||
$(DEPTH)/js/src/js-confdefs.h
|
||||
$(PYTHON) $(topsrcdir)/config/pythonpath.py \
|
||||
$(PLY_INCLUDE) \
|
||||
-I$(LIBXUL_DIST)/sdk/bin \
|
||||
$(srcdir)/dombindingsgen.py \
|
||||
--idlpath=$(DEPTH)/dist/idl \
|
||||
--stub-output dombindings_gen.cpp \
|
||||
--makedepend-output $(MDDEPDIR)/dombindingsgen.pp \
|
||||
$(srcdir)/dombindings.conf
|
||||
|
||||
DictionaryHelpers.$(OBJ_SUFFIX): DictionaryHelpers.cpp
|
||||
|
||||
DictionaryHelpers.h: DictionaryHelpers.cpp
|
||||
@ -158,7 +123,6 @@ DictionaryHelpers.h: DictionaryHelpers.cpp
|
||||
DictionaryHelpers.cpp: $(srcdir)/dictionary_helper_gen.conf \
|
||||
event_impl_gen.conf \
|
||||
$(srcdir)/dictionary_helper_gen.py \
|
||||
$(srcdir)/codegen.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/header.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/xpidl.py \
|
||||
$(DEPTH)/js/src/js-confdefs.h
|
||||
@ -183,7 +147,6 @@ GeneratedEvents.h: $(srcdir)/dictionary_helper_gen.conf \
|
||||
event_impl_gen.conf \
|
||||
$(srcdir)/dictionary_helper_gen.py \
|
||||
$(srcdir)/event_impl_gen.py \
|
||||
$(srcdir)/codegen.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/header.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/xpidl.py \
|
||||
$(DEPTH)/js/src/js-confdefs.h
|
||||
@ -200,7 +163,6 @@ GeneratedEvents.cpp: DictionaryHelpers.h \
|
||||
event_impl_gen.conf \
|
||||
$(srcdir)/dictionary_helper_gen.py \
|
||||
$(srcdir)/event_impl_gen.py \
|
||||
$(srcdir)/codegen.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/header.py \
|
||||
$(LIBXUL_DIST)/sdk/bin/xpidl.py \
|
||||
$(DEPTH)/js/src/js-confdefs.h
|
||||
@ -224,8 +186,6 @@ libs:: $(_EXTRA_EXPORT_FILES)
|
||||
GARBAGE += \
|
||||
dom_quickstubs.h \
|
||||
dom_quickstubs.cpp \
|
||||
dombindings_gen.h \
|
||||
dombindings_gen.cpp \
|
||||
DictionaryHelpers.h \
|
||||
DictionaryHelpers.cpp \
|
||||
GeneratedEvents.h \
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "AccessCheck.h"
|
||||
#include "nsJSUtils.h"
|
||||
|
||||
#include "dombindings.h"
|
||||
#include "nsWrapperCacheInlines.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
@ -482,14 +482,7 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper,
|
||||
}
|
||||
|
||||
nsISupports *identity;
|
||||
if (mozilla::dom::oldproxybindings::instanceIsProxy(obj)) {
|
||||
identity =
|
||||
static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
|
||||
} else if (!mozilla::dom::UnwrapDOMObjectToISupports(obj, identity)) {
|
||||
identity = nullptr;
|
||||
}
|
||||
|
||||
if (identity) {
|
||||
if (mozilla::dom::UnwrapDOMObjectToISupports(obj, identity)) {
|
||||
nsCOMPtr<nsIClassInfo> ci = do_QueryInterface(identity);
|
||||
|
||||
XPCCallContext ccx(JS_CALLER, cx);
|
||||
|
@ -417,16 +417,10 @@ SuspectDOMExpandos(nsPtrHashKey<JSObject> *key, void *arg)
|
||||
{
|
||||
Closure *closure = static_cast<Closure*>(arg);
|
||||
JSObject* obj = key->GetKey();
|
||||
nsISupports* native = nullptr;
|
||||
if (dom::oldproxybindings::instanceIsProxy(obj)) {
|
||||
native = static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
|
||||
}
|
||||
else {
|
||||
const dom::DOMClass* clasp;
|
||||
dom::DOMObjectSlot slot = GetDOMClass(obj, clasp);
|
||||
MOZ_ASSERT(slot != dom::eNonDOMObject && clasp->mDOMObjectIsISupports);
|
||||
native = dom::UnwrapDOMObject<nsISupports>(obj, slot);
|
||||
}
|
||||
const dom::DOMClass* clasp;
|
||||
dom::DOMObjectSlot slot = GetDOMClass(obj, clasp);
|
||||
MOZ_ASSERT(slot != dom::eNonDOMObject && clasp->mDOMObjectIsISupports);
|
||||
nsISupports* native = dom::UnwrapDOMObject<nsISupports>(obj, slot);
|
||||
closure->cb->NoteXPCOMRoot(native);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
@ -2395,7 +2389,6 @@ JSBool
|
||||
XPCJSRuntime::OnJSContextNew(JSContext *cx)
|
||||
{
|
||||
// if it is our first context then we need to generate our string ids
|
||||
JSBool ok = true;
|
||||
if (JSID_IS_VOID(mStrIDs[0])) {
|
||||
JS_SetGCParameterForThread(cx, JSGC_MAX_CODE_CACHE_BYTES, 16 * 1024 * 1024);
|
||||
{
|
||||
@ -2406,22 +2399,17 @@ XPCJSRuntime::OnJSContextNew(JSContext *cx)
|
||||
JSString* str = JS_InternString(cx, mStrings[i]);
|
||||
if (!str || !JS_ValueToId(cx, STRING_TO_JSVAL(str), &mStrIDs[i])) {
|
||||
mStrIDs[0] = JSID_VOID;
|
||||
ok = false;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
mStrJSVals[i] = STRING_TO_JSVAL(str);
|
||||
}
|
||||
}
|
||||
|
||||
ok = mozilla::dom::DefineStaticJSVals(cx) &&
|
||||
mozilla::dom::oldproxybindings::DefineStaticJSVals(cx);
|
||||
if (!ok)
|
||||
if (!mozilla::dom::DefineStaticJSVals(cx) ||
|
||||
!InternStaticDictionaryJSVals(cx)) {
|
||||
return false;
|
||||
|
||||
ok = InternStaticDictionaryJSVals(cx);
|
||||
}
|
||||
}
|
||||
if (!ok)
|
||||
return false;
|
||||
|
||||
XPCContext* xpc = new XPCContext(this, cx);
|
||||
if (!xpc)
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "AccessCheck.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "XrayWrapper.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
@ -1,642 +0,0 @@
|
||||
#!/usr/bin/env/python
|
||||
# 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/.
|
||||
|
||||
import xpidl
|
||||
import header
|
||||
import sys
|
||||
import os
|
||||
import string
|
||||
|
||||
# === Utils
|
||||
|
||||
def warn(msg):
|
||||
sys.stderr.write(msg + '\n')
|
||||
|
||||
def makeQuote(filename):
|
||||
return filename.replace(' ', '\\ ') # enjoy!
|
||||
|
||||
# === Types
|
||||
|
||||
def isVoidType(type):
|
||||
""" Return True if the given xpidl type is void. """
|
||||
return type.kind == 'builtin' and type.name == 'void'
|
||||
|
||||
def isStringType(t):
|
||||
t = xpidl.unaliasType(t)
|
||||
return t.kind == 'native' and (t.specialtype == 'astring' or t.specialtype == 'domstring');
|
||||
|
||||
def isInterfaceType(t):
|
||||
t = xpidl.unaliasType(t)
|
||||
assert t.kind in ('builtin', 'native', 'interface', 'forward')
|
||||
return t.kind in ('interface', 'forward')
|
||||
|
||||
def isSpecificInterfaceType(t, name):
|
||||
""" True if `t` is an interface type with the given name, or a forward
|
||||
declaration or typedef aliasing it.
|
||||
|
||||
`name` must not be the name of a typedef but the actual name of the
|
||||
interface.
|
||||
"""
|
||||
t = xpidl.unaliasType(t)
|
||||
return t.kind in ('interface', 'forward') and t.name == name
|
||||
|
||||
def isVariantType(t):
|
||||
return isSpecificInterfaceType(t, 'nsIVariant')
|
||||
|
||||
# === Reading the file
|
||||
|
||||
class UserError(Exception):
|
||||
pass
|
||||
|
||||
def findIDL(includePath, irregularFilenames, interfaceName):
|
||||
filename = irregularFilenames.get(interfaceName, interfaceName) + '.idl'
|
||||
for d in includePath:
|
||||
# Not os.path.join: we need a forward slash even on Windows because
|
||||
# this filename ends up in makedepend output.
|
||||
path = d + '/' + filename
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
raise UserError("No IDL file found for interface %s "
|
||||
"in include path %r"
|
||||
% (interfaceName, includePath))
|
||||
|
||||
# === Generating code
|
||||
|
||||
argumentUnboxingTemplates = {
|
||||
'octet':
|
||||
" uint32_t ${name}_u32;\n"
|
||||
" if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n"
|
||||
" return JS_FALSE;\n"
|
||||
" uint8_t ${name} = uint8_t(${name}_u32);\n",
|
||||
|
||||
'short':
|
||||
" int32_t ${name}_i32;\n"
|
||||
" if (!JS_ValueToECMAInt32(cx, ${argVal}, &${name}_i32))\n"
|
||||
" return JS_FALSE;\n"
|
||||
" int16_t ${name} = int16_t(${name}_i32);\n",
|
||||
|
||||
'unsigned short':
|
||||
" uint32_t ${name}_u32;\n"
|
||||
" if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}_u32))\n"
|
||||
" return JS_FALSE;\n"
|
||||
" uint16_t ${name} = uint16_t(${name}_u32);\n",
|
||||
|
||||
'long':
|
||||
" int32_t ${name};\n"
|
||||
" if (!JS_ValueToECMAInt32(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'unsigned long':
|
||||
" uint32_t ${name};\n"
|
||||
" if (!JS_ValueToECMAUint32(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'long long':
|
||||
" int64_t ${name};\n"
|
||||
" if (!JS::ToInt64(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'unsigned long long':
|
||||
" uint64_t ${name};\n"
|
||||
" if (!JS::ToUint64(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'float':
|
||||
" double ${name}_dbl;\n"
|
||||
" if (!JS_ValueToNumber(cx, ${argVal}, &${name}_dbl))\n"
|
||||
" return JS_FALSE;\n"
|
||||
" float ${name} = (float) ${name}_dbl;\n",
|
||||
|
||||
'double':
|
||||
" double ${name};\n"
|
||||
" if (!JS_ValueToNumber(cx, ${argVal}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'boolean':
|
||||
" bool ${name};\n"
|
||||
" JS_ValueToBoolean(cx, ${argVal}, &${name});\n",
|
||||
|
||||
'[astring]':
|
||||
" xpc_qsAString ${name}(cx, ${argVal}, ${argPtr});\n"
|
||||
" if (!${name}.IsValid())\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'[domstring]':
|
||||
" xpc_qsDOMString ${name}(cx, ${argVal}, ${argPtr}, "
|
||||
"xpc_qsDOMString::e${nullBehavior}, "
|
||||
"xpc_qsDOMString::e${undefinedBehavior});\n"
|
||||
" if (!${name}.IsValid())\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'string':
|
||||
" JSAutoByteString ${name}_bytes;\n"
|
||||
" if (!xpc_qsJsvalToCharStr(cx, ${argVal}, &${name}_bytes))\n"
|
||||
" return JS_FALSE;\n"
|
||||
" char *${name} = ${name}_bytes.ptr();\n",
|
||||
|
||||
'wstring':
|
||||
" const PRUnichar *${name};\n"
|
||||
" if (!xpc_qsJsvalToWcharStr(cx, ${argVal}, ${argPtr}, &${name}))\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'[cstring]':
|
||||
" xpc_qsACString ${name}(cx, ${argVal}, ${argPtr});\n"
|
||||
" if (!${name}.IsValid())\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'[utf8string]':
|
||||
" xpc_qsAUTF8String ${name}(cx, ${argVal}, ${argPtr});\n"
|
||||
" if (!${name}.IsValid())\n"
|
||||
" return JS_FALSE;\n",
|
||||
|
||||
'[jsval]':
|
||||
" jsval ${name} = ${argVal};\n"
|
||||
}
|
||||
|
||||
# From JSData2Native.
|
||||
#
|
||||
# Omitted optional arguments are treated as though the caller had passed JS
|
||||
# `null`; this behavior is from XPCWrappedNative::CallMethod. The 'jsval' type,
|
||||
# however, defaults to 'undefined'.
|
||||
#
|
||||
def writeArgumentUnboxing(f, i, name, type, optional, rvdeclared,
|
||||
nullBehavior, undefinedBehavior):
|
||||
# f - file to write to
|
||||
# i - int or None - Indicates the source jsval. If i is an int, the source
|
||||
# jsval is argv[i]; otherwise it is *vp. But if Python i >= C++ argc,
|
||||
# which can only happen if optional is True, the argument is missing;
|
||||
# use JSVAL_NULL as the source jsval instead.
|
||||
# name - str - name of the native C++ variable to create.
|
||||
# type - xpidl.{Interface,Native,Builtin} - IDL type of argument
|
||||
# optional - bool - True if the parameter is optional.
|
||||
# rvdeclared - bool - False if no |nsresult rv| has been declared earlier.
|
||||
|
||||
typeName = xpidl.getBuiltinOrNativeTypeName(type)
|
||||
|
||||
isSetter = (i is None)
|
||||
|
||||
if isSetter:
|
||||
argPtr = "vp"
|
||||
argVal = "*vp"
|
||||
elif optional:
|
||||
if typeName == "[jsval]":
|
||||
val = "JSVAL_VOID"
|
||||
else:
|
||||
val = "JSVAL_NULL"
|
||||
argVal = "(%d < argc ? argv[%d] : %s)" % (i, i, val)
|
||||
argPtr = "(%d < argc ? &argv[%d] : NULL)" % (i, i)
|
||||
else:
|
||||
argVal = "argv[%d]" % i
|
||||
argPtr = "&" + argVal
|
||||
|
||||
params = {
|
||||
'name': name,
|
||||
'argVal': argVal,
|
||||
'argPtr': argPtr,
|
||||
'nullBehavior': nullBehavior or 'DefaultNullBehavior',
|
||||
'undefinedBehavior': undefinedBehavior or 'DefaultUndefinedBehavior'
|
||||
}
|
||||
|
||||
if typeName is not None:
|
||||
template = argumentUnboxingTemplates.get(typeName)
|
||||
if template is not None:
|
||||
f.write(string.Template(template).substitute(params))
|
||||
return rvdeclared
|
||||
# else fall through; the type isn't supported yet.
|
||||
elif isInterfaceType(type):
|
||||
if type.name == 'nsIVariant':
|
||||
# Totally custom.
|
||||
template = (
|
||||
" nsCOMPtr<nsIVariant> ${name}(already_AddRefed<nsIVariant>("
|
||||
"XPCVariant::newVariant(cx, ${argVal})));\n"
|
||||
" if (!${name}) {\n"
|
||||
" xpc_qsThrowBadArg(cx, NS_ERROR_INVALID_ARG, vp, %d);\n"
|
||||
" return JS_FALSE;\n"
|
||||
" }\n") % i
|
||||
f.write(string.Template(template).substitute(params))
|
||||
return rvdeclared
|
||||
elif type.name == 'nsIAtom':
|
||||
# Should have special atomizing behavior. Fall through.
|
||||
pass
|
||||
else:
|
||||
if not rvdeclared:
|
||||
f.write(" nsresult rv;\n");
|
||||
f.write(" %s *%s;\n" % (type.name, name))
|
||||
f.write(" xpc_qsSelfRef %sref;\n" % name)
|
||||
f.write(" rv = xpc_qsUnwrapArg<%s>("
|
||||
"cx, %s, &%s, &%sref.ptr, %s);\n"
|
||||
% (type.name, argVal, name, name, argPtr))
|
||||
f.write(" if (NS_FAILED(rv)) {\n")
|
||||
if isSetter:
|
||||
f.write(" xpc_qsThrowBadSetterValue("
|
||||
"cx, rv, JSVAL_TO_OBJECT(*tvr.jsval_addr()), id);\n")
|
||||
else:
|
||||
f.write(" xpc_qsThrowBadArgWithDetails(cx, rv, %d, %s, %s);\n" % (i, "\"\"", "\"\""))
|
||||
f.write(" return JS_FALSE;\n"
|
||||
" }\n")
|
||||
return True
|
||||
|
||||
warn("Unable to unbox argument of type %s (native type %s)" % (type.name, typeName))
|
||||
if i is None:
|
||||
src = '*vp'
|
||||
else:
|
||||
src = 'argv[%d]' % i
|
||||
f.write(" !; // TODO - Unbox argument %s = %s\n" % (name, src))
|
||||
return rvdeclared
|
||||
|
||||
def writeResultDecl(f, member, varname):
|
||||
type = member.realtype
|
||||
|
||||
if isVoidType(type):
|
||||
return # nothing to declare
|
||||
|
||||
t = xpidl.unaliasType(type)
|
||||
if t.kind == 'builtin':
|
||||
if not t.nativename.endswith('*'):
|
||||
if type.kind == 'typedef':
|
||||
typeName = type.name # use it
|
||||
else:
|
||||
typeName = t.nativename
|
||||
f.write(" %s %s;\n" % (typeName, varname))
|
||||
return
|
||||
elif t.kind == 'native':
|
||||
name = xpidl.getBuiltinOrNativeTypeName(t)
|
||||
if name in ('[domstring]', '[astring]'):
|
||||
f.write(" nsString %s;\n" % varname)
|
||||
return
|
||||
elif name == '[jsval]':
|
||||
return # nothing to declare; see special case in outParamForm
|
||||
elif t.kind in ('interface', 'forward'):
|
||||
if member.kind == 'method' and member.notxpcom:
|
||||
f.write(" %s *%s;\n" % (type.name, varname))
|
||||
else:
|
||||
f.write(" nsCOMPtr<%s> %s;\n" % (type.name, varname))
|
||||
return
|
||||
|
||||
warn("Unable to declare result of type %s" % type.name)
|
||||
f.write(" !; // TODO - Declare out parameter `%s`.\n" % varname)
|
||||
|
||||
def outParamForm(name, type):
|
||||
type = xpidl.unaliasType(type)
|
||||
# If we start allowing [jsval] return types here, we need to tack
|
||||
# the return value onto the arguments list in the callers,
|
||||
# possibly, and handle properly returning it too. See bug 604198.
|
||||
assert type.kind != 'native' or type.specialtype != 'jsval'
|
||||
if type.kind == 'builtin':
|
||||
return '&' + name
|
||||
elif type.kind == 'native':
|
||||
if type.specialtype == 'jsval':
|
||||
return 'vp'
|
||||
elif type.modifier == 'ref':
|
||||
if isStringType(type):
|
||||
return '(nsAString&)' + name
|
||||
return name
|
||||
else:
|
||||
return '&' + name
|
||||
else:
|
||||
return 'getter_AddRefs(%s)' % name
|
||||
|
||||
# From NativeData2JS.
|
||||
resultConvTemplates = {
|
||||
'void':
|
||||
" ${jsvalRef} = JSVAL_VOID;\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'octet':
|
||||
" ${jsvalRef} = INT_TO_JSVAL(int32_t(result));\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'short':
|
||||
" ${jsvalRef} = INT_TO_JSVAL(int32_t(result));\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'long':
|
||||
" ${jsvalRef} = INT_TO_JSVAL(result);\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'long long':
|
||||
" return xpc_qsInt64ToJsval(cx, result, ${jsvalPtr};\n",
|
||||
|
||||
'unsigned short':
|
||||
" ${jsvalRef} = INT_TO_JSVAL(int32_t(result));\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'unsigned long':
|
||||
" ${jsvalRef} = UINT_TO_JSVAL(result);\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'unsigned long long':
|
||||
" return xpc_qsUint64ToJsval(cx, result, ${jsvalPtr});\n",
|
||||
|
||||
'float':
|
||||
" ${jsvalRef} = JS_NumberValue(result);\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'double':
|
||||
" ${jsvalRef} = JS_NumberValue(result);\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'boolean':
|
||||
" ${jsvalRef} = (result ? JSVAL_TRUE : JSVAL_FALSE);\n"
|
||||
" return JS_TRUE;\n",
|
||||
|
||||
'[astring]':
|
||||
" return xpc::StringToJsval(cx, result, ${jsvalPtr});\n",
|
||||
|
||||
'[domstring]':
|
||||
" return xpc::StringToJsval(cx, result, ${jsvalPtr});\n",
|
||||
|
||||
'[jsval]':
|
||||
# Here there's nothing to convert, because the result has already been
|
||||
# written directly to *rv. See the special case in outParamForm.
|
||||
" return JS_TRUE;\n"
|
||||
}
|
||||
|
||||
def writeResultConv(f, type, interfaceResultTemplate, jsvalPtr, jsvalRef):
|
||||
""" Emit code to convert the C++ variable `result` to a jsval.
|
||||
|
||||
The emitted code contains a return statement; it returns JS_TRUE on
|
||||
success, JS_FALSE on error.
|
||||
"""
|
||||
# From NativeData2JS.
|
||||
typeName = xpidl.getBuiltinOrNativeTypeName(type)
|
||||
if typeName is not None:
|
||||
template = resultConvTemplates.get(typeName)
|
||||
elif isInterfaceType(type):
|
||||
if isVariantType(type):
|
||||
template = (" XPCLazyCallContext lccx(JS_CALLER, cx, obj);\n"
|
||||
" return xpc_qsVariantToJsval(lccx, result, ${jsvalPtr});\n")
|
||||
else:
|
||||
template = (" if (!result) {\n"
|
||||
" *${jsvalPtr} = JSVAL_NULL;\n"
|
||||
" return JS_TRUE;\n"
|
||||
" }\n")
|
||||
template += interfaceResultTemplate
|
||||
|
||||
if template is not None:
|
||||
values = {'jsvalRef': jsvalRef,
|
||||
'jsvalPtr': jsvalPtr,
|
||||
'typeName': type.name}
|
||||
f.write(string.Template(template).substitute(values))
|
||||
return
|
||||
# else fall through; this type isn't supported yet
|
||||
|
||||
warn("Unable to convert result of type %s" % type.name)
|
||||
f.write(" !; // TODO - Convert `result` to jsval, store in `%s`.\n"
|
||||
% jsvalRef)
|
||||
f.write(" return xpc_qsThrow(cx, NS_ERROR_UNEXPECTED); // FIXME\n")
|
||||
|
||||
def validateParam(member, param):
|
||||
def pfail(msg):
|
||||
raise UserError(
|
||||
member.iface.name + '.' + member.name + ": "
|
||||
"parameter " + param.name + ": " + msg)
|
||||
|
||||
if param.iid_is is not None:
|
||||
pfail("iid_is parameters are not supported.")
|
||||
if param.size_is is not None:
|
||||
pfail("size_is parameters are not supported.")
|
||||
if param.retval:
|
||||
pfail("Unexpected retval parameter!")
|
||||
if param.paramtype in ('out', 'inout'):
|
||||
pfail("inout parameters are not supported.")
|
||||
if param.const or param.array or param.shared:
|
||||
pfail("I am a simple caveman.")
|
||||
|
||||
# returns the number of arguments that a method takes in JS (including optional arguments)
|
||||
def argumentsLength(member):
|
||||
assert member.kind == 'method'
|
||||
|
||||
inArgs = len(member.params)
|
||||
if inArgs and member.notxpcom and member.params[inArgs - 1].paramtype == 'out':
|
||||
if member.params[inArgs - 1].realtype.kind != 'native' or member.params[inArgs - 1].realtype.nativename != 'nsWrapperCache':
|
||||
pfail("We only support a wrapper cache as out argument")
|
||||
inArgs -= 1
|
||||
return inArgs
|
||||
|
||||
def writeStub(f, customMethodCalls, member, stubName, writeThisUnwrapping, writeCheckForFailure, writeResultWrapping, isSetter=False):
|
||||
""" Write a single quick stub (a custom SpiderMonkey getter/setter/method)
|
||||
for the specified XPCOM interface-member.
|
||||
"""
|
||||
if member.kind == 'method' and member.forward:
|
||||
member = member.iface.namemap[member.forward]
|
||||
|
||||
isAttr = (member.kind == 'attribute')
|
||||
isMethod = (member.kind == 'method')
|
||||
assert isAttr or isMethod
|
||||
isNotxpcom = isMethod and member.notxpcom
|
||||
isGetter = isAttr and not isSetter
|
||||
|
||||
signature = "static JSBool\n"
|
||||
if isAttr:
|
||||
# JSPropertyOp signature.
|
||||
if isSetter:
|
||||
signature += "%s(JSContext *cx, JSHandleObject obj, JSHandleId id, JSBool strict,%s JSMutableHandleValue vp_)\n"
|
||||
else:
|
||||
signature += "%s(JSContext *cx, JSHandleObject obj, JSHandleId id,%s JSMutableHandleValue vp_)\n"
|
||||
else:
|
||||
# JSFastNative.
|
||||
signature += "%s(JSContext *cx, unsigned argc,%s jsval *vp)\n"
|
||||
|
||||
customMethodCall = customMethodCalls.get(stubName, None)
|
||||
|
||||
if customMethodCall is None:
|
||||
customMethodCall = customMethodCalls.get(member.iface.name + '_', None)
|
||||
if customMethodCall is not None:
|
||||
if isMethod:
|
||||
code = customMethodCall.get('code', None)
|
||||
elif isGetter:
|
||||
code = customMethodCall.get('getter_code', None)
|
||||
else:
|
||||
code = customMethodCall.get('setter_code', None)
|
||||
else:
|
||||
code = None
|
||||
|
||||
if code is not None:
|
||||
templateName = member.iface.name
|
||||
if isGetter:
|
||||
templateName += '_Get'
|
||||
elif isSetter:
|
||||
templateName += '_Set'
|
||||
|
||||
# Generate the code for the stub, calling the template function
|
||||
# that's shared between the stubs. The stubs can't have additional
|
||||
# arguments, only the template function can.
|
||||
callTemplate = signature % (stubName, '')
|
||||
callTemplate += "{\n"
|
||||
|
||||
argumentValues = (customMethodCall['additionalArgumentValues']
|
||||
% header.methodNativeName(member))
|
||||
if isAttr:
|
||||
callTemplate += (" return %s(cx, obj, id%s, %s, vp_);\n"
|
||||
% (templateName, ", strict" if isSetter else "", argumentValues))
|
||||
else:
|
||||
callTemplate += (" return %s(cx, argc, %s, vp);\n"
|
||||
% (templateName, argumentValues))
|
||||
callTemplate += "}\n\n"
|
||||
|
||||
# Fall through and create the template function stub called from the
|
||||
# real stubs, but only generate the stub once. Otherwise, just write
|
||||
# out the call to the template function and return.
|
||||
templateGenerated = templateName + '_generated'
|
||||
if templateGenerated in customMethodCall:
|
||||
f.write(callTemplate)
|
||||
return
|
||||
customMethodCall[templateGenerated] = True
|
||||
|
||||
stubName = templateName
|
||||
else:
|
||||
callTemplate = ""
|
||||
else:
|
||||
callTemplate = ""
|
||||
code = customMethodCall.get('code', None)
|
||||
|
||||
# Function prolog.
|
||||
|
||||
# Only template functions can have additional arguments.
|
||||
if customMethodCall is None or not 'additionalArguments' in customMethodCall:
|
||||
additionalArguments = ''
|
||||
else:
|
||||
additionalArguments = " %s," % customMethodCall['additionalArguments']
|
||||
f.write(signature % (stubName, additionalArguments))
|
||||
f.write("{\n")
|
||||
f.write(" XPC_QS_ASSERT_CONTEXT_OK(cx);\n")
|
||||
|
||||
# Convert JSMutableHandleValue to jsval*
|
||||
if isAttr:
|
||||
f.write(" jsval *vp = vp_.address();\n")
|
||||
|
||||
# For methods, compute "this".
|
||||
if isMethod:
|
||||
f.write(" JSObject *obj = JS_THIS_OBJECT(cx, vp);\n"
|
||||
" if (!obj)\n"
|
||||
" return JS_FALSE;\n")
|
||||
|
||||
selfname = writeThisUnwrapping(f, member, isMethod, isGetter, customMethodCall)
|
||||
|
||||
rvdeclared = False
|
||||
if isMethod:
|
||||
inArgs = argumentsLength(member)
|
||||
# If there are any required arguments, check argc.
|
||||
requiredArgs = inArgs
|
||||
while requiredArgs and member.params[requiredArgs-1].optional:
|
||||
requiredArgs -= 1
|
||||
if requiredArgs:
|
||||
f.write(" if (argc < %d)\n" % requiredArgs)
|
||||
f.write(" return xpc_qsThrow(cx, "
|
||||
"NS_ERROR_XPC_NOT_ENOUGH_ARGS);\n")
|
||||
|
||||
# Convert in-parameters.
|
||||
if inArgs > 0:
|
||||
f.write(" jsval *argv = JS_ARGV(cx, vp);\n")
|
||||
for i in range(inArgs):
|
||||
param = member.params[i]
|
||||
argName = 'arg%d' % i
|
||||
argTypeKey = argName + 'Type'
|
||||
if customMethodCall is None or not argTypeKey in customMethodCall:
|
||||
validateParam(member, param)
|
||||
realtype = param.realtype
|
||||
else:
|
||||
realtype = xpidl.Forward(name=customMethodCall[argTypeKey],
|
||||
location='', doccomments='')
|
||||
# Emit code to convert this argument from jsval.
|
||||
rvdeclared = writeArgumentUnboxing(
|
||||
f, i, argName, realtype,
|
||||
optional=param.optional,
|
||||
rvdeclared=rvdeclared,
|
||||
nullBehavior=param.null,
|
||||
undefinedBehavior=param.undefined)
|
||||
if inArgs < len(member.params):
|
||||
f.write(" nsWrapperCache *cache;\n")
|
||||
elif isSetter:
|
||||
rvdeclared = writeArgumentUnboxing(f, None, 'arg0', member.realtype,
|
||||
optional=False,
|
||||
rvdeclared=rvdeclared,
|
||||
nullBehavior=member.null,
|
||||
undefinedBehavior=member.undefined)
|
||||
|
||||
canFail = not isNotxpcom and (customMethodCall is None or customMethodCall.get('canFail', True))
|
||||
if canFail and not rvdeclared:
|
||||
f.write(" nsresult rv;\n")
|
||||
rvdeclared = True
|
||||
|
||||
if code is not None:
|
||||
f.write("%s\n" % code)
|
||||
|
||||
if code is None or (isGetter and callTemplate is ""):
|
||||
debugGetter = code is not None
|
||||
if debugGetter:
|
||||
f.write("#ifdef DEBUG\n")
|
||||
f.write(" nsresult debug_rv;\n")
|
||||
f.write(" nsCOMPtr<%s> debug_self;\n"
|
||||
" CallQueryInterface(self, getter_AddRefs(debug_self));\n"
|
||||
% member.iface.name);
|
||||
prefix = 'debug_'
|
||||
else:
|
||||
prefix = ''
|
||||
|
||||
resultname = prefix + 'result'
|
||||
selfname = prefix + selfname
|
||||
nsresultname = prefix + 'rv'
|
||||
|
||||
# Prepare out-parameter.
|
||||
if isMethod or isGetter:
|
||||
writeResultDecl(f, member, resultname)
|
||||
|
||||
# Call the method.
|
||||
if isMethod:
|
||||
comName = header.methodNativeName(member)
|
||||
argv = ['arg' + str(i) for i in range(inArgs)]
|
||||
if inArgs < len(member.params):
|
||||
argv.append(outParamForm('cache', member.params[inArgs].realtype))
|
||||
if member.implicit_jscontext:
|
||||
argv.append('cx')
|
||||
if member.optional_argc:
|
||||
argv.append('argc - %d' % requiredArgs)
|
||||
if not isNotxpcom and not isVoidType(member.realtype):
|
||||
argv.append(outParamForm(resultname, member.realtype))
|
||||
args = ', '.join(argv)
|
||||
else:
|
||||
comName = header.attributeNativeName(member, isGetter)
|
||||
if isGetter:
|
||||
args = outParamForm(resultname, member.realtype)
|
||||
else:
|
||||
args = "arg0"
|
||||
if member.implicit_jscontext:
|
||||
args = "cx, " + args
|
||||
|
||||
f.write(" ")
|
||||
if canFail or debugGetter:
|
||||
f.write("%s = " % nsresultname)
|
||||
elif isNotxpcom:
|
||||
f.write("%s = " % resultname)
|
||||
f.write("%s->%s(%s);\n" % (selfname, comName, args))
|
||||
|
||||
if debugGetter:
|
||||
checkSuccess = "NS_SUCCEEDED(debug_rv)"
|
||||
if canFail:
|
||||
checkSuccess += " == NS_SUCCEEDED(rv)"
|
||||
f.write(" NS_ASSERTION(%s && "
|
||||
"xpc_qsSameResult(debug_result, result),\n"
|
||||
" \"Got the wrong answer from the custom "
|
||||
"method call!\");\n" % checkSuccess)
|
||||
f.write("#endif\n")
|
||||
|
||||
if canFail:
|
||||
# Check for errors.
|
||||
writeCheckForFailure(f, isMethod, isGetter)
|
||||
|
||||
# Convert the return value.
|
||||
if isMethod or isGetter:
|
||||
writeResultWrapping(f, member, 'vp', '*vp')
|
||||
else:
|
||||
f.write(" return JS_TRUE;\n")
|
||||
|
||||
# Epilog.
|
||||
f.write("}\n\n")
|
||||
|
||||
# Now write out the call to the template function.
|
||||
if customMethodCall is not None:
|
||||
f.write(callTemplate)
|
@ -5,7 +5,6 @@
|
||||
# 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/.
|
||||
|
||||
from codegen import *
|
||||
import sys, os.path, re, xpidl, itertools
|
||||
|
||||
# --makedepend-output support.
|
||||
@ -23,6 +22,9 @@ def strip_end(text, suffix):
|
||||
return text[:-len(suffix)]
|
||||
|
||||
# Copied from dombindingsgen.py
|
||||
def makeQuote(filename):
|
||||
return filename.replace(' ', '\\ ') # enjoy!
|
||||
|
||||
def writeMakeDependOutput(filename):
|
||||
print "Creating makedepend file", filename
|
||||
f = open(filename, 'w')
|
||||
|
@ -1,85 +0,0 @@
|
||||
# -*- Mode: python; -*-c
|
||||
# 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./
|
||||
|
||||
list_classes = [
|
||||
{
|
||||
'name': 'NodeList',
|
||||
'nativeClass': 'nsINodeList'
|
||||
},
|
||||
{
|
||||
'name': 'PropertyNodeList',
|
||||
'nativeClass': 'mozilla::dom::PropertyNodeList',
|
||||
'newBindingHeader': 'mozilla/dom/HTMLPropertiesCollectionBinding.h'
|
||||
},
|
||||
{
|
||||
'name': 'HTMLCollection',
|
||||
'nativeClass': 'nsIHTMLCollection'
|
||||
},
|
||||
{
|
||||
'name': 'HTMLOptionsCollection',
|
||||
'nativeClass': 'nsHTMLOptionCollection'
|
||||
},
|
||||
{
|
||||
'name': 'HTMLPropertiesCollection',
|
||||
'nativeClass': 'mozilla::dom::HTMLPropertiesCollection'
|
||||
},
|
||||
{
|
||||
'name': 'DOMTokenList',
|
||||
'nativeClass': 'nsDOMTokenList'
|
||||
},
|
||||
{
|
||||
'name': 'DOMSettableTokenList',
|
||||
'nativeClass': 'nsDOMSettableTokenList'
|
||||
},
|
||||
{
|
||||
'name': 'ClientRectList',
|
||||
'nativeClass': 'nsClientRectList'
|
||||
},
|
||||
{
|
||||
'name': 'PaintRequestList',
|
||||
'nativeClass': 'nsPaintRequestList'
|
||||
},
|
||||
{
|
||||
'name': 'FileList',
|
||||
'nativeClass': 'nsDOMFileList'
|
||||
},
|
||||
{
|
||||
'name': 'SVGLengthList',
|
||||
'nativeClass': 'mozilla::DOMSVGLengthList'
|
||||
},
|
||||
{
|
||||
'name': 'SVGNumberList',
|
||||
'nativeClass': 'mozilla::DOMSVGNumberList'
|
||||
},
|
||||
{
|
||||
'name': 'SVGPathSegList',
|
||||
'nativeClass': 'mozilla::DOMSVGPathSegList'
|
||||
},
|
||||
{
|
||||
'name': 'SVGPointList',
|
||||
'nativeClass': 'mozilla::DOMSVGPointList'
|
||||
},
|
||||
{
|
||||
'name': 'SVGTransformList',
|
||||
'nativeClass': 'mozilla::DOMSVGTransformList'
|
||||
}
|
||||
]
|
||||
|
||||
prefableClasses = {
|
||||
}
|
||||
|
||||
irregularFilenames = {
|
||||
'nsHTMLOptionCollection': 'nsHTMLSelectElement',
|
||||
'mozilla::dom::PropertyNodeList': 'HTMLPropertiesCollection',
|
||||
'nsClientRectList': 'nsClientRect',
|
||||
'nsPaintRequestList': 'nsPaintRequest',
|
||||
'nsDOMFileList': 'nsDOMFile',
|
||||
}
|
||||
|
||||
customInheritance = {
|
||||
'nsIDOMPropertyNodeList': 'nsIDOMNodeList',
|
||||
'nsIDOMHTMLOptionsCollection': 'nsIDOMHTMLCollection',
|
||||
'nsIDOMHTMLPropertiesCollection': 'nsIDOMHTMLCollection',
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,225 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=4 sw=4 et tw=99 ft=cpp:
|
||||
*
|
||||
* 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/. */
|
||||
|
||||
#ifndef dombindings_h
|
||||
#define dombindings_h
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsproxy.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace oldproxybindings {
|
||||
|
||||
class ProxyHandler : public DOMBaseProxyHandler {
|
||||
protected:
|
||||
ProxyHandler() : DOMBaseProxyHandler(false)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual bool isInstanceOf(JSObject *prototype) = 0;
|
||||
};
|
||||
|
||||
class NoType;
|
||||
class NoOp {
|
||||
public:
|
||||
typedef NoType* T;
|
||||
enum {
|
||||
hasOp = 0
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class Op {
|
||||
public:
|
||||
typedef Type T;
|
||||
enum {
|
||||
hasOp = 1
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class Getter : public Op<Type>
|
||||
{
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class Setter : public Op<Type>
|
||||
{
|
||||
};
|
||||
|
||||
template<class Getter, class Setter=NoOp>
|
||||
class Ops
|
||||
{
|
||||
public:
|
||||
typedef Getter G;
|
||||
typedef Setter S;
|
||||
};
|
||||
|
||||
typedef Ops<NoOp, NoOp> NoOps;
|
||||
|
||||
template<class ListType, class Base, class IndexOps, class NameOps=NoOps>
|
||||
class DerivedListClass {
|
||||
public:
|
||||
typedef ListType LT;
|
||||
typedef Base B;
|
||||
typedef IndexOps IO;
|
||||
typedef NameOps NOp;
|
||||
};
|
||||
|
||||
class NoBase {
|
||||
public:
|
||||
static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope,
|
||||
JSObject *receiver);
|
||||
static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
static nsISupports* nativeToSupports(nsISupports* aNative)
|
||||
{
|
||||
return aNative;
|
||||
}
|
||||
};
|
||||
|
||||
template<class ListType, class IndexOps, class NameOps=NoOps>
|
||||
class ListClass : public DerivedListClass<ListType, NoBase, IndexOps, NameOps> {
|
||||
};
|
||||
|
||||
template<class LC>
|
||||
class ListBase : public ProxyHandler {
|
||||
protected:
|
||||
typedef typename LC::LT ListType;
|
||||
typedef typename LC::B Base;
|
||||
typedef typename LC::IO::G::T IndexGetterType;
|
||||
typedef typename LC::IO::S::T IndexSetterType;
|
||||
typedef typename LC::NOp::G::T NameGetterType;
|
||||
typedef typename LC::NOp::S::T NameSetterType;
|
||||
enum {
|
||||
hasIndexGetter = LC::IO::G::hasOp,
|
||||
hasIndexSetter = LC::IO::S::hasOp,
|
||||
hasNameGetter = LC::NOp::G::hasOp,
|
||||
hasNameSetter = LC::NOp::S::hasOp
|
||||
};
|
||||
|
||||
private:
|
||||
friend void Register(nsScriptNameSpaceManager* aNameSpaceManager);
|
||||
|
||||
static ListBase<LC> instance;
|
||||
|
||||
static js::Class sInterfaceClass;
|
||||
|
||||
struct Properties {
|
||||
jsid &id;
|
||||
JSPropertyOp getter;
|
||||
JSStrictPropertyOp setter;
|
||||
};
|
||||
struct Methods {
|
||||
jsid &id;
|
||||
JSNative native;
|
||||
unsigned nargs;
|
||||
};
|
||||
|
||||
static Properties sProtoProperties[];
|
||||
static size_t sProtoPropertiesCount;
|
||||
static Methods sProtoMethods[];
|
||||
static size_t sProtoMethodsCount;
|
||||
|
||||
static JSObject *ensureExpandoObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
static JSBool length_getter(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp);
|
||||
|
||||
static inline bool getItemAt(ListType *list, uint32_t i, IndexGetterType &item);
|
||||
static inline bool setItemAt(JSContext *cx, ListType *list, uint32_t i, IndexSetterType item);
|
||||
|
||||
static inline bool namedItem(JSContext *cx, JSObject *obj, jsval *name, NameGetterType &result,
|
||||
bool *hasResult);
|
||||
|
||||
static inline bool getNamedItem(ListType *list, const nsAString& aName, NameGetterType &item);
|
||||
static inline bool setNamedItem(JSContext *cx, ListType *list, const nsAString& aName,
|
||||
NameSetterType item);
|
||||
|
||||
static bool getPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id, bool *found,
|
||||
JS::Value *vp);
|
||||
static bool hasPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id);
|
||||
|
||||
public:
|
||||
static JSObject *create(JSContext *cx, JSObject *scope, ListType *list,
|
||||
nsWrapperCache* cache);
|
||||
|
||||
static JSObject *getPrototype(JSContext *cx, JSObject *receiver);
|
||||
static bool DefineDOMInterface(JSContext *cx, JSObject *receiver, bool *enabled);
|
||||
bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
|
||||
JSPropertyDescriptor *desc);
|
||||
bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
|
||||
JSPropertyDescriptor *desc);
|
||||
bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
|
||||
JSPropertyDescriptor *desc);
|
||||
bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, JS::AutoIdVector &props);
|
||||
bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
|
||||
bool enumerate(JSContext *cx, JSObject *proxy, JS::AutoIdVector &props);
|
||||
|
||||
bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
|
||||
bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
|
||||
bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, JS::Value *vp);
|
||||
bool getElementIfPresent(JSContext *cx, JSObject *proxy, JSObject *receiver,
|
||||
uint32_t index, JS::Value *vp, bool *present);
|
||||
bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict,
|
||||
JS::Value *vp);
|
||||
bool keys(JSContext *cx, JSObject *proxy, JS::AutoIdVector &props);
|
||||
bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, JS::Value *vp);
|
||||
|
||||
/* Spidermonkey extensions. */
|
||||
bool hasInstance(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleValue vp, bool *bp);
|
||||
JSString *obj_toString(JSContext *cx, JSObject *proxy);
|
||||
void finalize(JSFreeOp *fop, JSObject *proxy);
|
||||
|
||||
static bool proxyHandlerIsList(js::BaseProxyHandler *handler) {
|
||||
return handler == &instance;
|
||||
}
|
||||
static bool objIsList(JSObject *obj) {
|
||||
return js::IsProxy(obj) && proxyHandlerIsList(js::GetProxyHandler(obj));
|
||||
}
|
||||
static inline bool instanceIsListObject(JSContext *cx, JSObject *obj, JSObject *callee);
|
||||
virtual bool isInstanceOf(JSObject *prototype)
|
||||
{
|
||||
return js::GetObjectClass(prototype) == &sInterfaceClass;
|
||||
}
|
||||
static inline ListType *getListObject(JSObject *obj);
|
||||
|
||||
static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope,
|
||||
JSObject *receiver);
|
||||
static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id,
|
||||
JSPropertyDescriptor *desc);
|
||||
static ListType *getNative(JSObject *proxy);
|
||||
static nsISupports* nativeToSupports(ListType* aNative)
|
||||
{
|
||||
return Base::nativeToSupports(aNative);
|
||||
}
|
||||
};
|
||||
|
||||
struct nsISupportsResult
|
||||
{
|
||||
nsISupportsResult()
|
||||
{
|
||||
}
|
||||
nsISupports *mResult;
|
||||
nsWrapperCache *mCache;
|
||||
};
|
||||
|
||||
JSObject* GetXrayExpandoChain(JSObject *obj);
|
||||
void SetXrayExpandoChain(JSObject *obj, JSObject *chain);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "dombindings_gen.h"
|
||||
|
||||
#endif /* dombindings_h */
|
@ -1,823 +0,0 @@
|
||||
#!/usr/bin/env/python
|
||||
# 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/.
|
||||
|
||||
from codegen import *
|
||||
import xpidl
|
||||
import os, re
|
||||
import string
|
||||
import UserDict
|
||||
|
||||
# === Preliminaries
|
||||
|
||||
# --makedepend-output support.
|
||||
make_dependencies = []
|
||||
make_targets = []
|
||||
|
||||
# === Reading the file
|
||||
|
||||
def addStubMember(memberId, member):
|
||||
# Add this member to the list.
|
||||
member.iface.stubMembers.append(member)
|
||||
|
||||
def checkStubMember(member):
|
||||
memberId = member.iface.name + "." + member.name
|
||||
if member.kind not in ('method', 'attribute'):
|
||||
raise UserError("Member %s is %r, not a method or attribute."
|
||||
% (memberId, member.kind))
|
||||
if member.noscript:
|
||||
raise UserError("%s %s is noscript."
|
||||
% (member.kind.capitalize(), memberId))
|
||||
if member.notxpcom:
|
||||
raise UserError(
|
||||
"%s %s: notxpcom methods are not supported."
|
||||
% (member.kind.capitalize(), memberId))
|
||||
|
||||
# Check for unknown properties.
|
||||
for attrname, value in vars(member).items():
|
||||
if value is True and attrname not in ('readonly','optional_argc',
|
||||
'implicit_jscontext','getter',
|
||||
'stringifier'):
|
||||
raise UserError("%s %s: unrecognized property %r"
|
||||
% (member.kind.capitalize(), memberId,
|
||||
attrname))
|
||||
|
||||
def loadIDL(parser, includePath, filename):
|
||||
make_dependencies.append(filename)
|
||||
text = open(filename, 'r').read()
|
||||
idl = parser.parse(text, filename=filename)
|
||||
idl.resolve(includePath, parser)
|
||||
return idl
|
||||
|
||||
|
||||
def firstCap(str):
|
||||
return str[0].upper() + str[1:]
|
||||
|
||||
class DOMClass(UserDict.DictMixin):
|
||||
def __init__(self, name, nativeClass, prefable):
|
||||
self.name = name
|
||||
self.base = None
|
||||
self.isBase = False
|
||||
self.nativeClass = nativeClass
|
||||
self.indexGetter = None
|
||||
self.indexSetter = None
|
||||
self.nameGetter = None
|
||||
self.nameSetter = None
|
||||
self.stringifier = False
|
||||
self.members = set()
|
||||
self.prefable = prefable
|
||||
|
||||
@staticmethod
|
||||
def getterNativeType(getter):
|
||||
if isStringType(getter.realtype):
|
||||
return 'nsString'
|
||||
type = getter.realtype
|
||||
if type.kind in ('interface', 'forward'):
|
||||
if not getter.notxpcom:
|
||||
return "nsCOMPtr<%s>" % type.name
|
||||
if len(getter.params) > 1:
|
||||
assert len(getter.params) == 2
|
||||
assert getter.params[1].realtype.kind == 'native' and getter.params[1].realtype.nativename == 'nsWrapperCache'
|
||||
return 'nsISupportsResult'
|
||||
return type.nativeType('in').strip()
|
||||
|
||||
@staticmethod
|
||||
def getterNativeCall(getter):
|
||||
if isStringType(getter.realtype):
|
||||
template = (" list->%s(index, item);\n"
|
||||
" return !DOMStringIsNull(item);\n")
|
||||
else:
|
||||
type = getter.realtype
|
||||
if type.kind in ('interface', 'forward'):
|
||||
if not getter.notxpcom:
|
||||
template = " return NS_SUCCEEDED(list->%s(index, getter_AddRefs(item)));\n"
|
||||
elif len(getter.params) > 1:
|
||||
template = (" item.mResult = list->%s(index, &item.mCache);\n"
|
||||
" return !!item.mResult;\n")
|
||||
else:
|
||||
template = (" item = list->%s(index);\n"
|
||||
" return !!item;\n")
|
||||
else:
|
||||
template = (" item = list->%s(index);\n"
|
||||
" return !!item;\n")
|
||||
|
||||
return template % header.methodNativeName(getter)
|
||||
|
||||
@staticmethod
|
||||
def setterNativeCall(setter):
|
||||
if setter.notxpcom:
|
||||
template = (" !; // TODO")
|
||||
else:
|
||||
template = (" nsresult rv = list->%s(index, item);\n"
|
||||
" return NS_SUCCEEDED(rv) ? true : Throw(cx, rv);\n")
|
||||
|
||||
return template % header.methodNativeName(setter)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
self.__dict__[name] = value
|
||||
if value:
|
||||
if name == 'indexGetter':
|
||||
if value.forward:
|
||||
self.realIndexGetter = value.iface.namemap[value.forward]
|
||||
else:
|
||||
self.realIndexGetter = value
|
||||
self.indexGetterType = self.getterNativeType(self.realIndexGetter)
|
||||
elif name == 'indexSetter':
|
||||
if value.forward:
|
||||
self.realIndexSetter = value.iface.namemap[value.forward]
|
||||
else:
|
||||
self.realIndexSetter = value
|
||||
self.indexSetterType = self.realIndexSetter.params[1].realtype.nativeType("in")
|
||||
elif name == 'nameGetter':
|
||||
if value.forward:
|
||||
self.realNameGetter = value.iface.namemap[value.forward]
|
||||
else:
|
||||
self.realNameGetter = value
|
||||
self.nameGetterType = self.getterNativeType(self.realNameGetter)
|
||||
elif name == 'nameSetter':
|
||||
if value.forward:
|
||||
self.realNameSetter = value.iface.namemap[value.forward]
|
||||
else:
|
||||
self.realNameSetter = value
|
||||
self.nameSetterType = self.getterNativeType(self.realNameSetter)
|
||||
|
||||
def __getitem__(self, key):
|
||||
assert type(key) == str
|
||||
|
||||
if key == 'indexGet':
|
||||
return DOMClass.getterNativeCall(self.realIndexGetter)
|
||||
|
||||
if key == 'indexSet':
|
||||
return DOMClass.setterNativeCall(self.realIndexSetter)
|
||||
|
||||
if key == 'nameGet':
|
||||
return DOMClass.getterNativeCall(self.realNameGetter)
|
||||
|
||||
if key == 'nameSet':
|
||||
return DOMClass.setterNativeCall(self.realNameSetter)
|
||||
|
||||
def ops(getterType, setterType):
|
||||
def opType(type):
|
||||
return type + (" " if type.endswith('>') else "")
|
||||
|
||||
if getterType or setterType:
|
||||
opsClass = ", Ops<"
|
||||
if getterType:
|
||||
opsClass += "Getter<" + opType(getterType) + ">"
|
||||
else:
|
||||
# Should we even support this?
|
||||
opsClass += "NoOp"
|
||||
if setterType:
|
||||
opsClass += ", Setter<" + opType(setterType) + ">"
|
||||
opsClass += " >"
|
||||
else:
|
||||
opsClass = ", NoOps"
|
||||
return opsClass
|
||||
|
||||
if key == 'indexOps':
|
||||
return ops(self.indexGetter and self.indexGetterType, self.indexSetter and self.indexSetterType)
|
||||
if key == 'nameOps':
|
||||
return ops(self.nameGetter and self.nameGetterType, self.nameSetter and self.nameSetterType) if self.nameGetter else ""
|
||||
|
||||
if key == 'listClass':
|
||||
if self.base:
|
||||
template = "DerivedListClass<${nativeClass}, ${base}Wrapper${indexOps}${nameOps} >"
|
||||
else:
|
||||
template = "ListClass<${nativeClass}${indexOps}${nameOps} >"
|
||||
return string.Template(template).substitute(self)
|
||||
|
||||
return self.__dict__[key]
|
||||
|
||||
def __cmp__(x, y):
|
||||
if x.isBase != y.isBase:
|
||||
return -1 if x.isBase else 1
|
||||
return cmp(x.name, y.name)
|
||||
|
||||
class Configuration:
|
||||
def __init__(self, filename, includePath):
|
||||
self.includePath = includePath
|
||||
config = {}
|
||||
execfile(filename, config)
|
||||
|
||||
# required settings
|
||||
if 'list_classes' not in config:
|
||||
raise UserError(filename + ": `%s` was not defined." % name)
|
||||
if 'list_classes' not in config:
|
||||
raise UserError(filename + ": `%s` was not defined." % name)
|
||||
self.list_classes = {}
|
||||
self.newBindingHeaders = []
|
||||
for clazz in config['list_classes']:
|
||||
self.list_classes[clazz['name']] = \
|
||||
DOMClass(name = clazz['name'],
|
||||
nativeClass = clazz['nativeClass'],
|
||||
prefable = False)
|
||||
self.newBindingHeaders.append(clazz.get('newBindingHeader', "mozilla/dom/" + clazz['name'] + "Binding.h"))
|
||||
|
||||
# optional settings
|
||||
if 'prefableClasses' in config:
|
||||
for clazz in config['prefableClasses']:
|
||||
self.list_classes[clazz] = DOMClass(name=clazz, nativeClass=config['prefableClasses'][clazz], prefable=True)
|
||||
|
||||
self.customInheritance = config.get('customInheritance', {})
|
||||
self.derivedClasses = {}
|
||||
self.irregularFilenames = config.get('irregularFilenames', {})
|
||||
self.customIncludes = config.get('customIncludes', [])
|
||||
|
||||
def readConfigFile(filename, includePath):
|
||||
# Read the config file.
|
||||
return Configuration(filename, includePath)
|
||||
|
||||
def completeConfiguration(conf, includePath, cachedir):
|
||||
# Now read IDL files to connect the information in the config file to
|
||||
# actual XPCOM interfaces, methods, and attributes.
|
||||
interfaces = []
|
||||
interfacesByName = {}
|
||||
parser = xpidl.IDLParser(cachedir)
|
||||
|
||||
def getInterface(interfaceName, errorLoc):
|
||||
iface = interfacesByName.get(interfaceName)
|
||||
if iface is None:
|
||||
idlFile = findIDL(conf.includePath, conf.irregularFilenames,
|
||||
interfaceName)
|
||||
idl = loadIDL(parser, conf.includePath, idlFile)
|
||||
if not idl.hasName(interfaceName):
|
||||
raise UserError("The interface %s was not found "
|
||||
"in the idl file %r."
|
||||
% (interfaceName, idlFile))
|
||||
iface = idl.getName(interfaceName, errorLoc)
|
||||
if not iface.attributes.scriptable:
|
||||
raise UserError("Interface %s is not scriptable. "
|
||||
"IDL file: %r." % (interfaceName, idlFile))
|
||||
iface.stubMembers = []
|
||||
interfaces.append(iface)
|
||||
interfacesByName[interfaceName] = iface
|
||||
return iface
|
||||
|
||||
stubbedInterfaces = []
|
||||
|
||||
for clazz in conf.list_classes.itervalues():
|
||||
interfaceName = 'nsIDOM' + clazz.name
|
||||
|
||||
iface = getInterface(interfaceName, errorLoc='looking for %r' % clazz.name)
|
||||
|
||||
for member in iface.members:
|
||||
if member.kind in ('method', 'attribute') and not member.noscript:
|
||||
#addStubMember(iface.name + '.' + member.name, member)
|
||||
clazz.members.add(member)
|
||||
|
||||
# Stub all scriptable members of this interface.
|
||||
while True:
|
||||
if iface not in stubbedInterfaces:
|
||||
stubbedInterfaces.append(iface)
|
||||
if not clazz.indexGetter and iface.ops['index']['getter']:
|
||||
clazz.indexGetter = iface.ops['index']['getter']
|
||||
if not clazz.indexSetter and iface.ops['index']['setter']:
|
||||
clazz.indexSetter = iface.ops['index']['setter']
|
||||
if not clazz.nameGetter and iface.ops['name']['getter']:
|
||||
clazz.nameGetter = iface.ops['name']['getter']
|
||||
if not clazz.nameSetter and iface.ops['name']['setter']:
|
||||
clazz.nameSetter = iface.ops['name']['setter']
|
||||
if not clazz.stringifier and iface.ops['stringifier']:
|
||||
clazz.stringifier = iface.ops['stringifier']
|
||||
interfaceName = conf.customInheritance.get(iface.name, iface.base)
|
||||
iface = getInterface(interfaceName, errorLoc='looking for %r' % clazz.name)
|
||||
if iface.name == 'nsISupports':
|
||||
break
|
||||
|
||||
assert iface.name.startswith('nsIDOM') and not iface.name.startswith('nsIDOMNS')
|
||||
clazz.base = iface.name[6:]
|
||||
# For now we only support base classes that are real DOM
|
||||
# list classes
|
||||
assert clazz.base in conf.list_classes
|
||||
if not conf.list_classes[clazz.base].isBase:
|
||||
conf.list_classes[clazz.base].isBase = True
|
||||
conf.derivedClasses[clazz.base] = []
|
||||
conf.derivedClasses[clazz.base].append(clazz.name)
|
||||
|
||||
# Now go through and check all the interfaces' members
|
||||
for iface in stubbedInterfaces:
|
||||
for member in iface.stubMembers:
|
||||
checkStubMember(member)
|
||||
|
||||
return interfaces
|
||||
|
||||
# === Generating the header file
|
||||
|
||||
def addType(types, type, map):
|
||||
def getTranslatedType(type):
|
||||
return map.get(type, type)
|
||||
|
||||
type = xpidl.unaliasType(type)
|
||||
if isInterfaceType(type) or (type.kind == 'native' and type.specialtype is None):
|
||||
types.add(getTranslatedType(type.name))
|
||||
|
||||
|
||||
def getTypes(classes, map):
|
||||
types = set()
|
||||
for clazz in classes.itervalues():
|
||||
types.add(map.get(clazz.nativeClass, clazz.nativeClass))
|
||||
if clazz.indexGetter:
|
||||
addType(types, clazz.realIndexGetter.realtype, map)
|
||||
if clazz.indexSetter:
|
||||
addType(types, clazz.realIndexSetter.realtype, map)
|
||||
if clazz.nameGetter:
|
||||
addType(types, clazz.realNameGetter.realtype, map)
|
||||
if clazz.nameSetter:
|
||||
addType(types, clazz.realNameSetter.realtype, map)
|
||||
return types
|
||||
|
||||
listDefinitionTemplate = (
|
||||
"class ${name} {\n"
|
||||
"public:\n"
|
||||
" template<typename I>\n"
|
||||
" static JSObject *create(JSContext *cx, JSObject *scope, I *list)\n"
|
||||
" {\n"
|
||||
" return create(cx, scope, list, list);\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" static bool objIsWrapper(JSObject *obj);\n"
|
||||
" static ${nativeClass} *getNative(JSObject *obj);\n"
|
||||
"\n"
|
||||
"private:\n"
|
||||
" static JSObject *create(JSContext *cx, JSObject *scope, ${nativeClass} *list, nsWrapperCache *cache);\n"
|
||||
"};"
|
||||
"\n"
|
||||
"\n")
|
||||
|
||||
def writeHeaderFile(filename, config):
|
||||
print "Creating header file", filename
|
||||
|
||||
headerMacro = '__gen_%s__' % filename.replace('.', '_')
|
||||
f = open(filename, 'w')
|
||||
try:
|
||||
f.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n"
|
||||
"#ifndef " + headerMacro + "\n"
|
||||
"#define " + headerMacro + "\n\n")
|
||||
|
||||
namespaces = []
|
||||
for type in sorted(getTypes(config.list_classes, {})):
|
||||
newNamespaces = type.split('::')
|
||||
type = newNamespaces.pop()
|
||||
j = 0
|
||||
for i in range(min(len(namespaces), len(newNamespaces))):
|
||||
if namespaces[i] != newNamespaces[i]:
|
||||
break
|
||||
j += 1
|
||||
for i in range(j, len(namespaces)):
|
||||
f.write("}\n")
|
||||
namespaces.pop()
|
||||
for i in range(j, len(newNamespaces)):
|
||||
f.write("namespace %s {\n" % newNamespaces[i])
|
||||
namespaces.append(newNamespaces[i])
|
||||
f.write("class %s;\n" % type)
|
||||
for namespace in namespaces:
|
||||
f.write("}\n")
|
||||
f.write("\n")
|
||||
|
||||
f.write("namespace mozilla {\n"
|
||||
"namespace dom {\n"
|
||||
"namespace oldproxybindings {\n\n")
|
||||
f.write("bool\n"
|
||||
"DefinePropertyStaticJSVals(JSContext *cx);\n\n")
|
||||
|
||||
for clazz in config.list_classes.itervalues():
|
||||
f.write(string.Template(listDefinitionTemplate).substitute(clazz))
|
||||
|
||||
f.write("\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
"}\n\n")
|
||||
f.write("#endif\n")
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
def writeMakeDependOutput(filename):
|
||||
print "Creating makedepend file", filename
|
||||
f = open(filename, 'w')
|
||||
try:
|
||||
if len(make_targets) > 0:
|
||||
f.write("%s:" % makeQuote(make_targets[0]))
|
||||
for filename in make_dependencies:
|
||||
f.write(' \\\n\t\t%s' % makeQuote(filename))
|
||||
f.write('\n\n')
|
||||
for filename in make_targets[1:]:
|
||||
f.write('%s: %s\n' % (makeQuote(filename), makeQuote(make_targets[0])))
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
# === Generating the source file
|
||||
|
||||
listTemplateHeader = (
|
||||
"// ${name}\n"
|
||||
"\n"
|
||||
"typedef ${listClass} ${name}Class;\n"
|
||||
"typedef ListBase<${name}Class> ${name}Wrapper;\n"
|
||||
"\n"
|
||||
"\n")
|
||||
|
||||
listTemplate = (
|
||||
"// ${name}\n"
|
||||
"\n"
|
||||
"template<>\n"
|
||||
"js::Class ${name}Wrapper::sInterfaceClass = {\n"
|
||||
" \"${name}\",\n"
|
||||
" 0,\n"
|
||||
" JS_PropertyStub, /* addProperty */\n"
|
||||
" JS_PropertyStub, /* delProperty */\n"
|
||||
" JS_PropertyStub, /* getProperty */\n"
|
||||
" JS_StrictPropertyStub, /* setProperty */\n"
|
||||
" JS_EnumerateStub,\n"
|
||||
" JS_ResolveStub,\n"
|
||||
" JS_ConvertStub,\n"
|
||||
" NULL, /* finalize */\n"
|
||||
" NULL, /* checkAccess */\n"
|
||||
" NULL, /* call */\n"
|
||||
" interface_hasInstance,\n"
|
||||
" NULL /* construct */\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"// static\n"
|
||||
"template<>\n"
|
||||
"bool\n"
|
||||
"${name}Wrapper::DefineDOMInterface(JSContext *cx, JSObject *receiver, bool *enabled)\n"
|
||||
"{\n"
|
||||
" bool ok = mozilla::dom::${name}Binding::DefineDOMInterface(cx, receiver, enabled);\n"
|
||||
" if (ok || *enabled) {\n"
|
||||
" return ok;\n"
|
||||
" }\n"
|
||||
" *enabled = true;\n"
|
||||
" return getPrototype(cx, receiver);\n"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
derivedClassTemplate = (
|
||||
"template<>\n"
|
||||
"bool\n"
|
||||
"${name}Wrapper::objIsList(JSObject *obj)\n"
|
||||
"{\n"
|
||||
" if (!js::IsProxy(obj))\n"
|
||||
" return false;\n"
|
||||
" js::BaseProxyHandler *handler = js::GetProxyHandler(obj);\n"
|
||||
" return proxyHandlerIsList(handler) ||\n"
|
||||
"${checkproxyhandlers};\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"template<>\n"
|
||||
"${nativeClass}*\n"
|
||||
"${name}Wrapper::getNative(JSObject *obj)\n"
|
||||
"{\n"
|
||||
" js::BaseProxyHandler *handler = js::GetProxyHandler(obj);\n"
|
||||
" if (proxyHandlerIsList(handler))\n"
|
||||
" return static_cast<${nativeClass}*>(js::GetProxyPrivate(obj).toPrivate());\n"
|
||||
"${castproxyhandlers}"
|
||||
"\n"
|
||||
" NS_RUNTIMEABORT(\"Unknown list type!\");\n"
|
||||
" return NULL;\n"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
prefableClassTemplate = (
|
||||
"template<>\n"
|
||||
"JSObject *\n"
|
||||
"${name}Wrapper::getPrototype(JSContext *cx, JSObject *receiver, bool *enabled)\n"
|
||||
"{\n"
|
||||
" XPCWrappedNativeScope *scope =\n"
|
||||
" XPCWrappedNativeScope::FindInJSObjectScope(cx, receiver);\n"
|
||||
" if (!scope)\n"
|
||||
" return NULL;\n"
|
||||
"\n"
|
||||
" if (!scope->NewDOMBindingsEnabled()) {\n"
|
||||
" *enabled = false;\n"
|
||||
" return NULL;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" *enabled = true;\n"
|
||||
" return getPrototype(cx, scope, receiver);\n"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
toStringTemplate = (
|
||||
"template<>\n"
|
||||
"JSString *\n"
|
||||
"${name}Wrapper::obj_toString(JSContext *cx, JSObject *proxy)\n"
|
||||
"{\n"
|
||||
" nsString result;\n"
|
||||
" nsresult rv = ${name}Wrapper::getListObject(proxy)->ToString(result);\n"
|
||||
" JSString *jsresult;\n"
|
||||
" return NS_SUCCEEDED(rv) && xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;\n"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
indexGetterTemplate = (
|
||||
"template<>\n"
|
||||
"bool\n"
|
||||
"${name}Wrapper::getItemAt(${nativeClass} *list, uint32_t index, ${indexGetterType} &item)\n"
|
||||
"{\n"
|
||||
"${indexGet}"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
indexSetterTemplate = (
|
||||
"template<>\n"
|
||||
"bool\n"
|
||||
"${name}Wrapper::setItemAt(JSContext *cx, ${nativeClass} *list, uint32_t index, ${indexSetterType} item)\n"
|
||||
"{\n"
|
||||
"${indexSet}"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
nameGetterTemplate = (
|
||||
"template<>\n"
|
||||
"bool\n"
|
||||
"${name}Wrapper::getNamedItem(${nativeClass} *list, const nsAString& index, ${nameGetterType} &item)\n"
|
||||
"{\n"
|
||||
"${nameGet}"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
nameSetterTemplate = (
|
||||
"template<>\n"
|
||||
"bool\n"
|
||||
"${name}Wrapper::setNamedItem(JSContext *cx, ${nativeClass} *list, const nsAString& index, ${nameSetterType} item)\n"
|
||||
"{\n"
|
||||
"${nameSet}"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
propertiesTemplate = (
|
||||
"template<>\n"
|
||||
"${name}Wrapper::Properties ${name}Wrapper::sProtoProperties[] = {\n"
|
||||
"${properties}\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"template<>\n"
|
||||
"size_t ${name}Wrapper::sProtoPropertiesCount = ArrayLength(${name}Wrapper::sProtoProperties);\n"
|
||||
"\n")
|
||||
|
||||
methodsTemplate = (
|
||||
"template<>\n"
|
||||
"${name}Wrapper::Methods ${name}Wrapper::sProtoMethods[] = {\n"
|
||||
"${methods}\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"template<>\n"
|
||||
"size_t ${name}Wrapper::sProtoMethodsCount = ArrayLength(${name}Wrapper::sProtoMethods);\n"
|
||||
"\n")
|
||||
|
||||
listTemplateFooter = (
|
||||
"template class ListBase<${name}Class>;\n"
|
||||
"\n"
|
||||
"JSObject*\n"
|
||||
"${name}::create(JSContext *cx, JSObject *scope, ${nativeClass} *list, nsWrapperCache *cache)\n"
|
||||
"{\n"
|
||||
" return ${name}Wrapper::create(cx, scope, list, cache);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"bool\n"
|
||||
"${name}::objIsWrapper(JSObject *obj)\n"
|
||||
"{\n"
|
||||
" return ${name}Wrapper::objIsList(obj);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"${nativeClass}*\n"
|
||||
"${name}::getNative(JSObject *obj)\n"
|
||||
"{\n"
|
||||
" return ${name}Wrapper::getListObject(obj);\n"
|
||||
"}\n"
|
||||
"\n")
|
||||
|
||||
def writeBindingStub(f, classname, member, stubName, isSetter=False):
|
||||
def writeThisUnwrapping(f, member, isMethod, isGetter, customMethodCall):
|
||||
if isMethod:
|
||||
f.write(" JSObject *callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));\n"
|
||||
" if (!%sWrapper::instanceIsListObject(cx, obj, callee))\n"
|
||||
" return false;\n" % classname)
|
||||
else:
|
||||
f.write(" if (!%sWrapper::instanceIsListObject(cx, obj, NULL))\n"
|
||||
" return false;\n" % classname)
|
||||
return "%sWrapper::getListObject(obj)" % classname
|
||||
def writeCheckForFailure(f, isMethod, isGeter):
|
||||
f.write(" if (NS_FAILED(rv))\n"
|
||||
" return xpc_qsThrowMethodFailedWithDetails(cx, rv, \"%s\", \"%s\");\n" % (classname, member.name))
|
||||
def writeResultWrapping(f, member, jsvalPtr, jsvalRef):
|
||||
if member.kind == 'method' and member.notxpcom and len(member.params) > 0 and member.params[len(member.params) - 1].paramtype == 'out':
|
||||
assert member.params[len(member.params) - 1].realtype.kind == 'native' and member.params[len(member.params) - 1].realtype.nativename == 'nsWrapperCache'
|
||||
template = " return Wrap(cx, obj, result, cache, ${jsvalPtr});\n"
|
||||
else:
|
||||
template = " return Wrap(cx, obj, result, ${jsvalPtr});\n"
|
||||
writeResultConv(f, member.realtype, template, jsvalPtr, jsvalRef)
|
||||
|
||||
writeStub(f, {}, member, stubName, writeThisUnwrapping, writeCheckForFailure, writeResultWrapping, isSetter)
|
||||
|
||||
def writeAttrStubs(f, classname, attr):
|
||||
getterName = classname + '_' + header.attributeNativeName(attr, True)
|
||||
writeBindingStub(f, classname, attr, getterName)
|
||||
if attr.readonly:
|
||||
setterName = 'xpc_qsGetterOnlyPropertyStub'
|
||||
else:
|
||||
setterName = (classname + '_'
|
||||
+ header.attributeNativeName(attr, False))
|
||||
writeBindingStub(f, classname, attr, setterName, isSetter=True)
|
||||
|
||||
return " { s_%s_id, %s, %s }" % (attr.name, getterName, setterName)
|
||||
|
||||
def writeMethodStub(f, classname, method):
|
||||
stubName = classname + '_' + header.methodNativeName(method)
|
||||
writeBindingStub(f, classname, method, stubName)
|
||||
return " { s_%s_id, %s, %i }" % (method.name, stubName, argumentsLength(method))
|
||||
|
||||
def writeStubFile(filename, config, interfaces):
|
||||
print "Creating stub file", filename
|
||||
make_targets.append(filename)
|
||||
|
||||
f = open(filename, 'w')
|
||||
filesIncluded = set()
|
||||
|
||||
headerFilename = re.sub(r'(\.cpp)?$', '.h', filename)
|
||||
|
||||
try:
|
||||
f.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n")
|
||||
|
||||
f.write("#include \"nsScriptNameSpaceManager.h\"\n")
|
||||
types = getTypes(config.list_classes, config.irregularFilenames)
|
||||
for clazz in config.list_classes.itervalues():
|
||||
for member in clazz.members:
|
||||
addType(types, member.realtype, config.irregularFilenames)
|
||||
if member.kind == 'method':
|
||||
for p in member.params:
|
||||
addType(types, p.realtype, config.irregularFilenames)
|
||||
|
||||
f.write("".join([("#include \"%s.h\"\n" % re.sub(r'(([^:]+::)*)', '', type)) for type in sorted(types)]))
|
||||
for newBindingHeader in config.newBindingHeaders:
|
||||
f.write("#include \"" + newBindingHeader + "\"\n")
|
||||
f.write("\n")
|
||||
|
||||
f.write("namespace mozilla {\n"
|
||||
"namespace dom {\n"
|
||||
"namespace oldproxybindings {\n\n")
|
||||
|
||||
f.write("// Property name ids\n\n")
|
||||
|
||||
ids = set()
|
||||
for clazz in config.list_classes.itervalues():
|
||||
assert clazz.indexGetter
|
||||
ids.add(clazz.indexGetter.name)
|
||||
if clazz.indexSetter:
|
||||
ids.add(clazz.indexSetter.name)
|
||||
if clazz.nameGetter:
|
||||
ids.add(clazz.nameGetter.name)
|
||||
if clazz.stringifier:
|
||||
ids.add('toString')
|
||||
for member in clazz.members:
|
||||
if member.name != 'length':
|
||||
ids.add(member.name)
|
||||
|
||||
ids = sorted(ids)
|
||||
for id in ids:
|
||||
f.write("static jsid s_%s_id = JSID_VOID;\n" % id)
|
||||
f.write("\n"
|
||||
"bool\n"
|
||||
"DefinePropertyStaticJSVals(JSContext *cx)\n"
|
||||
"{\n")
|
||||
f.write(" return %s;" % (" &&\n ".join([("SET_JSID_TO_STRING(cx, %s)" % id) for id in ids])))
|
||||
f.write("\n"
|
||||
"}\n\n")
|
||||
|
||||
classes = sorted(config.list_classes.values())
|
||||
|
||||
f.write("// Typedefs\n\n")
|
||||
|
||||
for clazz in classes:
|
||||
f.write(string.Template(listTemplateHeader).substitute(clazz))
|
||||
|
||||
f.write("// Implementation\n\n")
|
||||
|
||||
for clazz in classes:
|
||||
f.write(string.Template(listTemplate).substitute(clazz))
|
||||
derivedClasses = config.derivedClasses.get(clazz.name, None)
|
||||
if derivedClasses:
|
||||
# If this hits we might need to do something better than just compare instance pointers
|
||||
assert len(derivedClasses) <= 3
|
||||
checkproxyhandlers = "||\n".join(map(lambda d: " %sWrapper::proxyHandlerIsList(handler)" % d, derivedClasses))
|
||||
castproxyhandlers = "\n".join(map(lambda d: " if (%sWrapper::proxyHandlerIsList(handler))\n return %sWrapper::getNative(obj);\n" % (d, d), derivedClasses))
|
||||
f.write(string.Template(derivedClassTemplate).substitute(clazz, checkproxyhandlers=checkproxyhandlers, castproxyhandlers=castproxyhandlers))
|
||||
if clazz.prefable:
|
||||
f.write(string.Template(prefableClassTemplate).substitute(clazz))
|
||||
methodsList = []
|
||||
propertiesList = []
|
||||
if clazz.stringifier:
|
||||
f.write(string.Template(toStringTemplate).substitute(clazz))
|
||||
if clazz.stringifier.name != 'toString':
|
||||
methodsList.append(" { s_toString_id, %s_%s, 0 }", clazz.name, header.methodNativeName(clazz.stringifier))
|
||||
if clazz.indexGetter:
|
||||
#methodsList.append(" { s_%s_id, &item, 1 }" % clazz.indexGetter.name)
|
||||
f.write(string.Template(indexGetterTemplate).substitute(clazz))
|
||||
methodsList.append(" { s_iterator_id, JS_ArrayIterator, 0}")
|
||||
if clazz.indexSetter:
|
||||
f.write(string.Template(indexSetterTemplate).substitute(clazz))
|
||||
if clazz.nameGetter:
|
||||
#methodsList.append(" { s_%s_id, &namedItem, 1 }" % clazz.nameGetter.name)
|
||||
f.write(string.Template(nameGetterTemplate).substitute(clazz))
|
||||
if clazz.nameSetter:
|
||||
f.write(string.Template(nameSetterTemplate).substitute(clazz))
|
||||
for member in sorted(clazz.members, key=lambda member: member.name):
|
||||
if member.name == 'length':
|
||||
if not member.readonly:
|
||||
setterName = (clazz.name + '_' + header.attributeNativeName(member, False))
|
||||
writeBindingStub(f, clazz.name, member, setterName, isSetter=True)
|
||||
else:
|
||||
setterName = "NULL"
|
||||
|
||||
propertiesList.append(" { mozilla::dom::s_length_id, length_getter, %s }" % setterName)
|
||||
continue
|
||||
|
||||
isAttr = (member.kind == 'attribute')
|
||||
isMethod = (member.kind == 'method')
|
||||
assert isAttr or isMethod
|
||||
|
||||
if isMethod:
|
||||
methodsList.append(writeMethodStub(f, clazz.name, member))
|
||||
else:
|
||||
propertiesList.append(writeAttrStubs(f, clazz.name, member))
|
||||
|
||||
if len(propertiesList) > 0:
|
||||
f.write(string.Template(propertiesTemplate).substitute(clazz, properties=",\n".join(propertiesList)))
|
||||
if len(methodsList) > 0:
|
||||
f.write(string.Template(methodsTemplate).substitute(clazz, methods=",\n".join(methodsList)))
|
||||
f.write(string.Template(listTemplateFooter).substitute(clazz))
|
||||
|
||||
f.write("// Register prototypes\n\n")
|
||||
|
||||
f.write("void\n"
|
||||
"Register(nsScriptNameSpaceManager* aNameSpaceManager)\n"
|
||||
"{\n"
|
||||
"#define REGISTER_PROTO(_dom_class) \\\n"
|
||||
" aNameSpaceManager->RegisterDefineDOMInterface(NS_LITERAL_STRING(#_dom_class), _dom_class##Wrapper::DefineDOMInterface, nullptr);\n\n"""
|
||||
"\n")
|
||||
for clazz in config.list_classes.itervalues():
|
||||
f.write(" REGISTER_PROTO(%s);\n" % clazz.name)
|
||||
f.write("\n"
|
||||
"#undef REGISTER_PROTO\n"
|
||||
"}\n\n")
|
||||
|
||||
f.write("}\n"
|
||||
"}\n"
|
||||
"}\n")
|
||||
finally:
|
||||
f.close()
|
||||
|
||||
def main():
|
||||
from optparse import OptionParser
|
||||
o = OptionParser(usage="usage: %prog [options] configfile")
|
||||
o.add_option('-o', "--stub-output",
|
||||
type='string', dest='stub_output', default=None,
|
||||
help="Quick stub C++ source output file", metavar="FILE")
|
||||
o.add_option('--header-output', type='string', default=None,
|
||||
help="Quick stub header output file", metavar="FILE")
|
||||
o.add_option('--makedepend-output', type='string', default=None,
|
||||
help="gnumake dependencies output file", metavar="FILE")
|
||||
o.add_option('--idlpath', type='string', default='.',
|
||||
help="colon-separated directories to search for idl files",
|
||||
metavar="PATH")
|
||||
o.add_option('--cachedir', dest='cachedir', default='',
|
||||
help="Directory in which to cache lex/parse tables.")
|
||||
o.add_option("--verbose-errors", action='store_true', default=False,
|
||||
help="When an error happens, display the Python traceback.")
|
||||
(options, filenames) = o.parse_args()
|
||||
|
||||
if len(filenames) != 1:
|
||||
o.error("Exactly one config filename is needed.")
|
||||
filename = filenames[0]
|
||||
|
||||
if options.cachedir != '':
|
||||
sys.path.append(options.cachedir)
|
||||
if not os.path.isdir(options.cachedir):
|
||||
os.makedirs(options.cachedir)
|
||||
|
||||
try:
|
||||
includePath = options.idlpath.split(':')
|
||||
conf = readConfigFile(filename,
|
||||
includePath=includePath)
|
||||
if options.header_output is not None:
|
||||
writeHeaderFile(options.header_output, conf)
|
||||
elif options.stub_output is not None:
|
||||
interfaces = completeConfiguration(conf,
|
||||
includePath=includePath,
|
||||
cachedir=options.cachedir)
|
||||
writeStubFile(options.stub_output, conf, interfaces)
|
||||
if options.makedepend_output is not None:
|
||||
writeMakeDependOutput(options.makedepend_output)
|
||||
except Exception, exc:
|
||||
if options.verbose_errors:
|
||||
raise
|
||||
elif isinstance(exc, (UserError, xpidl.IDLError)):
|
||||
warn(str(exc))
|
||||
elif isinstance(exc, OSError):
|
||||
warn("%s: %s" % (exc.__class__.__name__, exc))
|
||||
else:
|
||||
raise
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -5,7 +5,6 @@
|
||||
# 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/.
|
||||
|
||||
from codegen import *
|
||||
import sys, os.path, re, xpidl, itertools
|
||||
|
||||
# --makedepend-output support.
|
||||
@ -18,6 +17,9 @@ def strip_end(text, suffix):
|
||||
return text[:-len(suffix)]
|
||||
|
||||
# Copied from dombindingsgen.py
|
||||
def makeQuote(filename):
|
||||
return filename.replace(' ', '\\ ') # enjoy!
|
||||
|
||||
def writeMakeDependOutput(filename):
|
||||
print "Creating makedepend file", filename
|
||||
f = open(filename, 'w')
|
||||
|
@ -31,7 +31,6 @@
|
||||
#endif
|
||||
|
||||
#include "XPCQuickStubs.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/TextDecoderBinding.h"
|
||||
@ -847,11 +846,6 @@ NoteGCThingXPCOMChildren(js::Class *clasp, JSObject *obj,
|
||||
clasp->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "xpc_GetJSPrivate(obj)");
|
||||
cb.NoteXPCOMChild(static_cast<nsISupports*>(xpc_GetJSPrivate(obj)));
|
||||
} else if (oldproxybindings::instanceIsProxy(obj)) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "js::GetProxyPrivate(obj)");
|
||||
nsISupports *identity =
|
||||
static_cast<nsISupports*>(js::GetProxyPrivate(obj).toPrivate());
|
||||
cb.NoteXPCOMChild(identity);
|
||||
} else {
|
||||
const DOMClass* domClass;
|
||||
DOMObjectSlot slot = GetDOMClass(obj, domClass);
|
||||
@ -1423,21 +1417,10 @@ nsXPConnect::GetNativeOfWrapper(JSContext * aJSContext,
|
||||
if (obj2)
|
||||
return (nsISupports*)xpc_GetJSPrivate(obj2);
|
||||
|
||||
if (mozilla::dom::IsDOMProxy(aJSObj) ||
|
||||
mozilla::dom::oldproxybindings::instanceIsProxy(aJSObj)) {
|
||||
// FIXME: Provide a fast non-refcounting way to get the canonical
|
||||
// nsISupports from the proxy.
|
||||
nsISupports *supports =
|
||||
static_cast<nsISupports*>(js::GetProxyPrivate(aJSObj).toPrivate());
|
||||
nsCOMPtr<nsISupports> canonical = do_QueryInterface(supports);
|
||||
return canonical.get();
|
||||
}
|
||||
|
||||
nsISupports* supports = nullptr;
|
||||
if (mozilla::dom::UnwrapDOMObjectToISupports(aJSObj, supports))
|
||||
return supports;
|
||||
|
||||
return nullptr;
|
||||
mozilla::dom::UnwrapDOMObjectToISupports(aJSObj, supports);
|
||||
nsCOMPtr<nsISupports> canonical = do_QueryInterface(supports);
|
||||
return canonical;
|
||||
}
|
||||
|
||||
/* JSObjectPtr getJSObjectOfWrapper (in JSContextPtr aJSContext, in JSObjectPtr aJSObj); */
|
||||
@ -1466,8 +1449,7 @@ nsXPConnect::GetJSObjectOfWrapper(JSContext * aJSContext,
|
||||
*_retval = obj2;
|
||||
return NS_OK;
|
||||
}
|
||||
if (mozilla::dom::IsDOMProxy(aJSObj) ||
|
||||
mozilla::dom::oldproxybindings::instanceIsProxy(aJSObj)) {
|
||||
if (mozilla::dom::IsDOMObject(aJSObj)) {
|
||||
*_retval = aJSObj;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -304,28 +304,10 @@ namespace dom {
|
||||
extern int HandlerFamily;
|
||||
inline void* ProxyFamily() { return &HandlerFamily; }
|
||||
|
||||
class DOMBaseProxyHandler : public js::BaseProxyHandler {
|
||||
protected:
|
||||
DOMBaseProxyHandler(bool aNewDOMProxy) : js::BaseProxyHandler(ProxyFamily()),
|
||||
mNewDOMProxy(aNewDOMProxy)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
bool mNewDOMProxy;
|
||||
};
|
||||
|
||||
inline bool IsNewProxyBinding(js::BaseProxyHandler* handler)
|
||||
{
|
||||
MOZ_ASSERT(handler->family() == ProxyFamily());
|
||||
return static_cast<DOMBaseProxyHandler*>(handler)->mNewDOMProxy;
|
||||
}
|
||||
|
||||
inline bool IsDOMProxy(JSObject *obj)
|
||||
{
|
||||
return js::IsProxy(obj) &&
|
||||
js::GetProxyHandler(obj)->family() == ProxyFamily() &&
|
||||
IsNewProxyBinding(js::GetProxyHandler(obj));
|
||||
js::GetProxyHandler(obj)->family() == ProxyFamily();
|
||||
}
|
||||
|
||||
typedef bool
|
||||
@ -339,21 +321,6 @@ DefineStaticJSVals(JSContext *cx);
|
||||
void
|
||||
Register(nsScriptNameSpaceManager* aNameSpaceManager);
|
||||
|
||||
namespace oldproxybindings {
|
||||
|
||||
inline bool instanceIsProxy(JSObject *obj)
|
||||
{
|
||||
return js::IsProxy(obj) &&
|
||||
js::GetProxyHandler(obj)->family() == ProxyFamily() &&
|
||||
!IsNewProxyBinding(js::GetProxyHandler(obj));
|
||||
}
|
||||
extern bool
|
||||
DefineStaticJSVals(JSContext *cx);
|
||||
void
|
||||
Register(nsScriptNameSpaceManager* aNameSpaceManager);
|
||||
|
||||
} // namespace oldproxybindings
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -30,10 +30,7 @@
|
||||
ok("2" in list, "in operator works");
|
||||
|
||||
is(win.document.body.removeChild(win.document.body.lastChild), list2, "remove last paragraph element");
|
||||
if (SpecialPowers.getBoolPref("dom.new_bindings"))
|
||||
ok(!("2" in list), "in operator doesn't see phantom element");
|
||||
else
|
||||
todo(!("2" in list), "in operator doesn't see phantom element");
|
||||
ok(!("2" in list), "in operator doesn't see phantom element");
|
||||
is(list[2], undefined, "no node there!");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -107,8 +107,6 @@ FilteringWrapper<Base, Policy>::enter(JSContext *cx, JSObject *wrapper, jsid id,
|
||||
#define SCSOW FilteringWrapper<SameCompartmentSecurityWrapper, OnlyIfSubjectIsSystem>
|
||||
#define XOW FilteringWrapper<XrayWrapper<CrossCompartmentSecurityWrapper>, \
|
||||
CrossOriginAccessiblePropertiesOnly>
|
||||
#define PXOW FilteringWrapper<XrayProxy, \
|
||||
CrossOriginAccessiblePropertiesOnly>
|
||||
#define DXOW FilteringWrapper<XrayDOM, \
|
||||
CrossOriginAccessiblePropertiesOnly>
|
||||
#define NNXOW FilteringWrapper<CrossCompartmentSecurityWrapper, \
|
||||
@ -126,7 +124,6 @@ template<> SOW SOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG |
|
||||
template<> SCSOW SCSOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG |
|
||||
WrapperFactory::SOW_FLAG);
|
||||
template<> XOW XOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG);
|
||||
template<> PXOW PXOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG);
|
||||
template<> DXOW DXOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG);
|
||||
template<> NNXOW NNXOW::singleton(WrapperFactory::SCRIPT_ACCESS_ONLY_FLAG);
|
||||
template<> LW LW::singleton(WrapperFactory::SHADOWING_FORBIDDEN);
|
||||
@ -137,7 +134,6 @@ template<> XCW XCW::singleton(0);
|
||||
|
||||
template class SOW;
|
||||
template class XOW;
|
||||
template class PXOW;
|
||||
template class DXOW;
|
||||
template class NNXOW;
|
||||
template class LW;
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "ChromeObjectWrapper.h"
|
||||
|
||||
#include "xpcprivate.h"
|
||||
#include "dombindings.h"
|
||||
#include "XPCMaps.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "jsfriendapi.h"
|
||||
@ -324,8 +323,6 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO
|
||||
XrayType type = GetXrayType(obj);
|
||||
if (type == XrayForDOMObject) {
|
||||
wrapper = &XrayDOM::singleton;
|
||||
} else if (type == XrayForDOMProxyObject) {
|
||||
wrapper = &XrayProxy::singleton;
|
||||
} else if (type == XrayForWrappedNative) {
|
||||
typedef XrayWrapper<CrossCompartmentWrapper> Xray;
|
||||
wrapper = &Xray::singleton;
|
||||
@ -356,8 +353,6 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO
|
||||
wrapper = &FilteringWrapper<Xray, CrossOriginAccessiblePropertiesOnly>::singleton;
|
||||
} else if (mozilla::dom::IsDOMObject(obj)) {
|
||||
wrapper = &FilteringWrapper<XrayDOM, CrossOriginAccessiblePropertiesOnly>::singleton;
|
||||
} else if (mozilla::dom::oldproxybindings::instanceIsProxy(obj)) {
|
||||
wrapper = &FilteringWrapper<XrayProxy, CrossOriginAccessiblePropertiesOnly>::singleton;
|
||||
} else if (IsComponentsObject(obj)) {
|
||||
wrapper = &FilteringWrapper<CrossCompartmentSecurityWrapper,
|
||||
ComponentsObjectPolicy>::singleton;
|
||||
@ -422,8 +417,6 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO
|
||||
wrapper = &CrossCompartmentWrapper::singleton;
|
||||
} else if (type == XrayForDOMObject) {
|
||||
wrapper = &XrayDOM::singleton;
|
||||
} else if (type == XrayForDOMProxyObject) {
|
||||
wrapper = &XrayProxy::singleton;
|
||||
} else {
|
||||
typedef XrayWrapper<CrossCompartmentWrapper> Xray;
|
||||
wrapper = &Xray::singleton;
|
||||
@ -441,9 +434,6 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO
|
||||
} else if (type == XrayForDOMObject) {
|
||||
wrapper = &FilteringWrapper<XrayDOM,
|
||||
CrossOriginAccessiblePropertiesOnly>::singleton;
|
||||
} else if (type == XrayForDOMProxyObject) {
|
||||
wrapper = &FilteringWrapper<XrayProxy,
|
||||
CrossOriginAccessiblePropertiesOnly>::singleton;
|
||||
} else {
|
||||
typedef XrayWrapper<CrossCompartmentSecurityWrapper> Xray;
|
||||
|
||||
@ -571,8 +561,6 @@ WrapperFactory::WrapForSameCompartmentXray(JSContext *cx, JSObject *obj)
|
||||
Wrapper *wrapper = NULL;
|
||||
if (type == XrayForWrappedNative)
|
||||
wrapper = &XrayWrapper<DirectWrapper>::singleton;
|
||||
else if (type == XrayForDOMProxyObject)
|
||||
wrapper = &XrayWrapper<DirectWrapper, ProxyXrayTraits>::singleton;
|
||||
else if (type == XrayForDOMObject)
|
||||
wrapper = &XrayWrapper<DirectWrapper, DOMXrayTraits>::singleton;
|
||||
else
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "nsJSUtils.h"
|
||||
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "dombindings.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
|
||||
@ -53,9 +52,6 @@ GetXrayType(JSObject *obj)
|
||||
if (mozilla::dom::IsDOMObject(obj))
|
||||
return XrayForDOMObject;
|
||||
|
||||
if (mozilla::dom::oldproxybindings::instanceIsProxy(obj))
|
||||
return XrayForDOMProxyObject;
|
||||
|
||||
js::Class* clasp = js::GetObjectClass(obj);
|
||||
if (IS_WRAPPER_CLASS(clasp) || clasp->ext.innerObject) {
|
||||
NS_ASSERTION(clasp->ext.innerObject || IS_WN_WRAPPER_OBJECT(obj),
|
||||
@ -223,38 +219,6 @@ public:
|
||||
static XPCWrappedNativeXrayTraits singleton;
|
||||
};
|
||||
|
||||
class ProxyXrayTraits : public XrayTraits
|
||||
{
|
||||
public:
|
||||
static bool resolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder, jsid id,
|
||||
bool set, JSPropertyDescriptor *desc);
|
||||
virtual bool resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper, JSObject *wrapper,
|
||||
JSObject *holder, jsid id, bool set,
|
||||
JSPropertyDescriptor *desc);
|
||||
static bool enumerateNames(JSContext *cx, JSObject *wrapper, unsigned flags,
|
||||
JS::AutoIdVector &props);
|
||||
|
||||
static bool isResolving(JSContext *cx, JSObject *holder, jsid id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void preserveWrapper(JSObject *target) { };
|
||||
|
||||
typedef ResolvingIdDummy ResolvingIdImpl;
|
||||
|
||||
virtual JSObject* createHolder(JSContext *cx, JSObject *wrapper);
|
||||
|
||||
virtual JSObject* getExpandoChain(JSObject *obj) {
|
||||
return mozilla::dom::oldproxybindings::GetXrayExpandoChain(obj);
|
||||
}
|
||||
virtual void setExpandoChain(JSObject *obj, JSObject *chain) {
|
||||
mozilla::dom::oldproxybindings::SetXrayExpandoChain(obj, chain);
|
||||
}
|
||||
|
||||
static ProxyXrayTraits singleton;
|
||||
};
|
||||
|
||||
class DOMXrayTraits : public XrayTraits
|
||||
{
|
||||
public:
|
||||
@ -288,7 +252,6 @@ public:
|
||||
};
|
||||
|
||||
XPCWrappedNativeXrayTraits XPCWrappedNativeXrayTraits::singleton;
|
||||
ProxyXrayTraits ProxyXrayTraits::singleton;
|
||||
DOMXrayTraits DOMXrayTraits::singleton;
|
||||
|
||||
XrayTraits*
|
||||
@ -297,8 +260,6 @@ GetXrayTraits(JSObject *obj)
|
||||
switch (GetXrayType(obj)) {
|
||||
case XrayForDOMObject:
|
||||
return &DOMXrayTraits::singleton;
|
||||
case XrayForDOMProxyObject:
|
||||
return &ProxyXrayTraits::singleton;
|
||||
case XrayForWrappedNative:
|
||||
return &XPCWrappedNativeXrayTraits::singleton;
|
||||
default:
|
||||
@ -1210,57 +1171,6 @@ XPCWrappedNativeXrayTraits::construct(JSContext *cx, JSObject *wrapper,
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
ProxyXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder,
|
||||
jsid id, bool set, JSPropertyDescriptor *desc)
|
||||
{
|
||||
JSObject *obj = getTargetObject(wrapper);
|
||||
return js::GetProxyHandler(obj)->getPropertyDescriptor(cx, wrapper, id, set, desc);
|
||||
}
|
||||
|
||||
bool
|
||||
ProxyXrayTraits::resolveOwnProperty(JSContext *cx, js::Wrapper &jsWrapper, JSObject *wrapper,
|
||||
JSObject *holder, jsid id, bool set, PropertyDescriptor *desc)
|
||||
{
|
||||
// Call the common code.
|
||||
bool ok = XrayTraits::resolveOwnProperty(cx, jsWrapper, wrapper, holder,
|
||||
id, set, desc);
|
||||
if (!ok || desc->obj)
|
||||
return ok;
|
||||
|
||||
JSObject *obj = getTargetObject(wrapper);
|
||||
ok = js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, set, desc);
|
||||
if (ok) {
|
||||
// The 'not found' property descriptor has obj == NULL.
|
||||
if (desc->obj)
|
||||
desc->obj = wrapper;
|
||||
}
|
||||
|
||||
// Own properties don't get cached on the holder. Just return.
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool
|
||||
ProxyXrayTraits::enumerateNames(JSContext *cx, JSObject *wrapper, unsigned flags,
|
||||
JS::AutoIdVector &props)
|
||||
{
|
||||
JSObject *obj = getTargetObject(wrapper);
|
||||
if (flags & (JSITER_OWNONLY | JSITER_HIDDEN))
|
||||
return js::GetProxyHandler(obj)->getOwnPropertyNames(cx, wrapper, props);
|
||||
|
||||
return js::GetProxyHandler(obj)->enumerate(cx, wrapper, props);
|
||||
}
|
||||
|
||||
// The 'holder' here isn't actually of [[Class]] HolderClass like those used by
|
||||
// XPCWrappedNativeXrayTraits. Instead, it's a funny hybrid of the 'expando' and
|
||||
// 'holder' properties. However, we store it in the same slot. Exercise caution.
|
||||
JSObject*
|
||||
ProxyXrayTraits::createHolder(JSContext *cx, JSObject *wrapper)
|
||||
{
|
||||
return JS_NewObjectWithGivenProto(cx, nullptr, nullptr,
|
||||
JS_GetGlobalForObject(cx, wrapper));
|
||||
}
|
||||
|
||||
bool
|
||||
DOMXrayTraits::resolveNativeProperty(JSContext *cx, JSObject *wrapper, JSObject *holder, jsid id,
|
||||
bool set, JSPropertyDescriptor *desc)
|
||||
@ -1392,7 +1302,7 @@ XrayToString(JSContext *cx, unsigned argc, jsval *vp)
|
||||
|
||||
nsAutoString result(NS_LITERAL_STRING("[object XrayWrapper "));
|
||||
JSObject *obj = &js::GetProxyPrivate(wrapper).toObject();
|
||||
if (IsDOMProxy(obj) || oldproxybindings::instanceIsProxy(obj)) {
|
||||
if (IsDOMProxy(obj)) {
|
||||
JSString *wrapperStr = js::GetProxyHandler(wrapper)->obj_toString(cx, wrapper);
|
||||
size_t length;
|
||||
const jschar* chars = JS_GetStringCharsAndLength(cx, wrapperStr, &length);
|
||||
@ -1813,11 +1723,6 @@ template <> XRAY XRAY::singleton(0);
|
||||
template class XRAY;
|
||||
#undef XRAY
|
||||
|
||||
#define XRAY XrayWrapper<CrossCompartmentWrapper, ProxyXrayTraits >
|
||||
template <> XRAY XRAY::singleton(0);
|
||||
template class XRAY;
|
||||
#undef XRAY
|
||||
|
||||
#define XRAY XrayWrapper<CrossCompartmentWrapper, DOMXrayTraits >
|
||||
template <> XRAY XRAY::singleton(0);
|
||||
template class XRAY;
|
||||
@ -1830,11 +1735,6 @@ template <> XRAY XRAY::singleton(0);
|
||||
template class XRAY;
|
||||
#undef XRAY
|
||||
|
||||
#define XRAY XrayWrapper<DirectWrapper, ProxyXrayTraits >
|
||||
template <> XRAY XRAY::singleton(0);
|
||||
template class XRAY;
|
||||
#undef XRAY
|
||||
|
||||
#define XRAY XrayWrapper<DirectWrapper, DOMXrayTraits >
|
||||
template <> XRAY XRAY::singleton(0);
|
||||
template class XRAY;
|
||||
|
@ -46,7 +46,6 @@ class DOMXrayTraits;
|
||||
|
||||
enum XrayType {
|
||||
XrayForDOMObject,
|
||||
XrayForDOMProxyObject,
|
||||
XrayForWrappedNative,
|
||||
NotXray
|
||||
};
|
||||
@ -94,7 +93,6 @@ class XrayWrapper : public Base {
|
||||
JS::AutoIdVector &props);
|
||||
};
|
||||
|
||||
typedef XrayWrapper<js::CrossCompartmentWrapper, ProxyXrayTraits > XrayProxy;
|
||||
typedef XrayWrapper<js::CrossCompartmentWrapper, DOMXrayTraits > XrayDOM;
|
||||
|
||||
class SandboxProxyHandler : public js::IndirectWrapper {
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
|
||||
nsIContent* get() const {
|
||||
if (XBLInvolved()) {
|
||||
return mNodes->GetNodeAt(mIndex);
|
||||
return mNodes->Item(mIndex);
|
||||
}
|
||||
|
||||
return mChild;
|
||||
|
@ -422,7 +422,7 @@ nsFrameManager::ClearAllUndisplayedContentIn(nsIContent* aParentContent)
|
||||
uint32_t length;
|
||||
list->GetLength(&length);
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
nsIContent* child = list->GetNodeAt(i);
|
||||
nsIContent* child = list->Item(i);
|
||||
if (child->GetParent() != aParentContent) {
|
||||
ClearUndisplayedContentIn(child, child->GetParent());
|
||||
}
|
||||
|
@ -681,7 +681,6 @@ pref("dom.min_background_timeout_value", 1000);
|
||||
|
||||
// Use the new DOM bindings (only affects any scopes created after the pref is
|
||||
// changed)
|
||||
pref("dom.new_bindings", true);
|
||||
pref("dom.experimental_bindings", true);
|
||||
|
||||
// Don't use new input types
|
||||
|
@ -471,20 +471,6 @@ class BaseInterface(object):
|
||||
if not isinstance(m, CDATA):
|
||||
self.namemap.set(m)
|
||||
|
||||
self.ops = {
|
||||
'index':
|
||||
{
|
||||
'getter': None,
|
||||
'setter': None
|
||||
},
|
||||
'name':
|
||||
{
|
||||
'getter': None,
|
||||
'setter': None
|
||||
},
|
||||
'stringifier': None
|
||||
}
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.name == other.name and self.location == other.location
|
||||
|
||||
@ -521,16 +507,8 @@ class BaseInterface(object):
|
||||
if self.attributes.scriptable and realbase.attributes.builtinclass and not self.attributes.builtinclass:
|
||||
raise IDLError("interface '%s' is not builtinclass but derives from builtinclass '%s'" % (self.name, self.base), self.location)
|
||||
|
||||
forwardedMembers = set()
|
||||
for member in self.members:
|
||||
member.resolve(self)
|
||||
if member.kind is 'method' and member.forward:
|
||||
forwardedMembers.add(member.forward)
|
||||
for member in self.members:
|
||||
if member.kind is 'method' and member.name in forwardedMembers:
|
||||
forwardedMembers.remove(member.name)
|
||||
for member in forwardedMembers:
|
||||
raise IDLError("member '%s' on interface '%s' forwards to '%s' which is not on the interface itself" % (member.name, self.name, member.forward), self.location)
|
||||
|
||||
# The number 250 is NOT arbitrary; this number is the maximum number of
|
||||
# stub entries defined in xpcom/reflect/xptcall/public/genstubs.pl
|
||||
@ -823,10 +801,6 @@ class Method(object):
|
||||
nostdcall = False
|
||||
optional_argc = False
|
||||
deprecated = False
|
||||
getter = False
|
||||
setter = False
|
||||
stringifier = False
|
||||
forward = None
|
||||
|
||||
def __init__(self, type, name, attlist, paramlist, location, doccomments, raises):
|
||||
self.type = type
|
||||
@ -845,13 +819,6 @@ class Method(object):
|
||||
|
||||
self.binaryname = value
|
||||
continue
|
||||
if name == 'forward':
|
||||
if value is None:
|
||||
raise IDLError("forward attribute requires a value",
|
||||
aloc)
|
||||
|
||||
self.forward = value
|
||||
continue
|
||||
|
||||
if value is not None:
|
||||
raise IDLError("Unexpected attribute value", aloc)
|
||||
@ -868,18 +835,6 @@ class Method(object):
|
||||
self.deprecated = True
|
||||
elif name == 'nostdcall':
|
||||
self.nostdcall = True
|
||||
elif name == 'getter':
|
||||
if (len(self.params) != 1):
|
||||
raise IDLError("Methods marked as getter must take 1 argument", aloc)
|
||||
self.getter = True
|
||||
elif name == 'setter':
|
||||
if (len(self.params) != 2):
|
||||
raise IDLError("Methods marked as setter must take 2 arguments", aloc)
|
||||
self.setter = True
|
||||
elif name == 'stringifier':
|
||||
if (len(self.params) != 0):
|
||||
raise IDLError("Methods marked as stringifier must take 0 arguments", aloc)
|
||||
self.stringifier = True
|
||||
else:
|
||||
raise IDLError("Unexpected attribute '%s'" % name, aloc)
|
||||
|
||||
@ -892,34 +847,6 @@ class Method(object):
|
||||
self.realtype = self.iface.idl.getName(self.type, self.location)
|
||||
for p in self.params:
|
||||
p.resolve(self)
|
||||
if self.getter:
|
||||
if getBuiltinOrNativeTypeName(self.params[0].realtype) == 'unsigned long':
|
||||
ops = 'index'
|
||||
else:
|
||||
if getBuiltinOrNativeTypeName(self.params[0].realtype) != '[domstring]':
|
||||
raise IDLError("a getter must take a single unsigned long or DOMString argument" % self.iface.name, self.location)
|
||||
ops = 'name'
|
||||
if self.iface.ops[ops]['getter']:
|
||||
raise IDLError("a %s getter was already defined on interface '%s'" % (ops, self.iface.name), self.location)
|
||||
self.iface.ops[ops]['getter'] = self
|
||||
if self.setter:
|
||||
if getBuiltinOrNativeTypeName(self.params[0].realtype) == 'unsigned long':
|
||||
ops = 'index'
|
||||
else:
|
||||
if getBuiltinOrNativeTypeName(self.params[0].realtype) != '[domstring]':
|
||||
print getBuiltinOrNativeTypeName(self.params[0].realtype)
|
||||
raise IDLError("a setter must take a unsigned long or DOMString argument" % self.iface.name, self.location)
|
||||
ops = 'name'
|
||||
if self.iface.ops[ops]['setter']:
|
||||
raise IDLError("a %s setter was already defined on interface '%s'" % (ops, self.iface.name), self.location)
|
||||
self.iface.ops[ops]['setter'] = self
|
||||
if self.stringifier:
|
||||
if self.iface.ops['stringifier']:
|
||||
raise IDLError("a stringifier was already defined on interface '%s'" % self.iface.name, self.location)
|
||||
if getBuiltinOrNativeTypeName(self.realtype) != '[domstring]':
|
||||
raise IDLError("'stringifier' attribute can only be used on methods returning DOMString",
|
||||
self.location)
|
||||
self.iface.ops['stringifier'] = self
|
||||
for p in self.params:
|
||||
if p.retval and p != self.params[-1]:
|
||||
raise IDLError("'retval' parameter '%s' is not the last parameter" % p.name, self.location)
|
||||
|
Loading…
Reference in New Issue
Block a user