diff --git a/accessible/src/base/nsAccTreeWalker.cpp b/accessible/src/base/nsAccTreeWalker.cpp index 9411008bdef..2a2383db040 100644 --- a/accessible/src/base/nsAccTreeWalker.cpp +++ b/accessible/src/base/nsAccTreeWalker.cpp @@ -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; diff --git a/accessible/src/xforms/nsXFormsAccessible.cpp b/accessible/src/xforms/nsXFormsAccessible.cpp index e1b3c739d60..de523ddbfb8 100644 --- a/accessible/src/xforms/nsXFormsAccessible.cpp +++ b/accessible/src/xforms/nsXFormsAccessible.cpp @@ -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 DOMNode(do_QueryInterface(content)); diff --git a/content/base/public/FragmentOrElement.h b/content/base/public/FragmentOrElement.h index f29391c7c26..463293e641b 100644 --- a/content/base/public/FragmentOrElement.h +++ b/content/base/public/FragmentOrElement.h @@ -62,6 +62,7 @@ public: // nsINodeList interface virtual int32_t IndexOf(nsIContent* aContent); + virtual nsIContent* Item(uint32_t aIndex); void DropReference() { diff --git a/content/base/public/nsIDOMFileList.idl b/content/base/public/nsIDOMFileList.idl index 218761e8ab1..31e6f380f2c 100644 --- a/content/base/public/nsIDOMFileList.idl +++ b/content/base/public/nsIDOMFileList.idl @@ -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); }; diff --git a/content/base/public/nsINodeList.h b/content/base/public/nsINodeList.h index 207bf92d677..abf7362d04f 100644 --- a/content/base/public/nsINodeList.h +++ b/content/base/public/nsINodeList.h @@ -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); diff --git a/content/base/src/FragmentOrElement.cpp b/content/base/src/FragmentOrElement.cpp index c15e8545a4f..7e72a546601 100644 --- a/content/base/src/FragmentOrElement.cpp +++ b/content/base/src/FragmentOrElement.cpp @@ -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); } } diff --git a/content/base/src/nsContentList.cpp b/content/base/src/nsContentList.cpp index e5de7e06179..af930628194 100644 --- a/content/base/src/nsContentList.cpp +++ b/content/base/src/nsContentList.cpp @@ -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) diff --git a/content/base/src/nsContentList.h b/content/base/src/nsContentList.h index 671c8fe3d98..84fbec0e021 100644 --- a/content/base/src/nsContentList.h +++ b/content/base/src/nsContentList.h @@ -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); diff --git a/content/base/src/nsDOMFile.cpp b/content/base/src/nsDOMFile.cpp index 5f183c501ad..c38a2a32462 100644 --- a/content/base/src/nsDOMFile.cpp +++ b/content/base/src/nsDOMFile.cpp @@ -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 diff --git a/content/base/src/nsDOMSettableTokenList.cpp b/content/base/src/nsDOMSettableTokenList.cpp index 39f7c893a6f..e48edd747da 100644 --- a/content/base/src/nsDOMSettableTokenList.cpp +++ b/content/base/src/nsDOMSettableTokenList.cpp @@ -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); } diff --git a/content/base/src/nsDOMTokenList.cpp b/content/base/src/nsDOMTokenList.cpp index b59d23b9260..3a42639c3db 100644 --- a/content/base/src/nsDOMTokenList.cpp +++ b/content/base/src/nsDOMTokenList.cpp @@ -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); } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 671d1af2820..eca4f533a40 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -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, diff --git a/content/base/src/nsReferencedElement.cpp b/content/base/src/nsReferencedElement.cpp index 7be718d6ea6..71807e08d02 100644 --- a/content/base/src/nsReferencedElement.cpp +++ b/content/base/src/nsReferencedElement.cpp @@ -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); } } diff --git a/content/events/src/nsPaintRequest.cpp b/content/events/src/nsPaintRequest.cpp index 22ec478c811..efcda4eb320 100644 --- a/content/events/src/nsPaintRequest.cpp +++ b/content/events/src/nsPaintRequest.cpp @@ -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); -} diff --git a/content/html/content/public/nsIHTMLCollection.h b/content/html/content/public/nsIHTMLCollection.h index f57b2d99377..280c94864e9 100644 --- a/content/html/content/public/nsIHTMLCollection.h +++ b/content/html/content/public/nsIHTMLCollection.h @@ -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); diff --git a/content/html/content/src/HTMLPropertiesCollection.cpp b/content/html/content/src/HTMLPropertiesCollection.cpp index 5ce7325d72c..ebc553641a5 100644 --- a/content/html/content/src/HTMLPropertiesCollection.cpp +++ b/content/html/content/src/HTMLPropertiesCollection.cpp @@ -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 propertyList; - if (!mNamedItemEntries.Get(aName, getter_AddRefs(propertyList))) { - propertyList = new PropertyNodeList(this, mRoot, aName); - mNamedItemEntries.Put(aName, propertyList); - } - *aCache = propertyList; - return static_cast(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) diff --git a/content/html/content/src/HTMLPropertiesCollection.h b/content/html/content/src/HTMLPropertiesCollection.h index f513e984074..06c05921ba1 100644 --- a/content/html/content/src/HTMLPropertiesCollection.h +++ b/content/html/content/src/HTMLPropertiesCollection.h @@ -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& aResult, ErrorResult& aError); + virtual nsIContent* Item(uint32_t aIndex); NS_DECL_NSIDOMPROPERTYNODELIST NS_DECL_CYCLE_COLLECTING_ISUPPORTS diff --git a/content/html/content/src/nsClientRect.cpp b/content/html/content/src/nsClientRect.cpp index 53ece17b225..5e63e7d8e1d 100644 --- a/content/html/content/src/nsClientRect.cpp +++ b/content/html/content/src/nsClientRect.cpp @@ -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 diff --git a/content/html/content/src/nsHTMLFieldSetElement.cpp b/content/html/content/src/nsHTMLFieldSetElement.cpp index 7f88ef3746c..533f9ba63c0 100644 --- a/content/html/content/src/nsHTMLFieldSetElement.cpp +++ b/content/html/content/src/nsHTMLFieldSetElement.cpp @@ -99,7 +99,7 @@ nsHTMLFieldSetElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, uint32_t length = mElements->Length(true); for (uint32_t i=0; i(mElements->GetNodeAt(i)) + static_cast(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(mElements->GetNodeAt(i)) + static_cast(mElements->Item(i)) ->FieldSetFirstLegendChanged(aNotify); } } diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index 8c7f715fc71..ccb3df787ee 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -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) diff --git a/content/html/content/src/nsHTMLSelectElement.cpp b/content/html/content/src/nsHTMLSelectElement.cpp index 85b1f1bf554..654a9c386fd 100644 --- a/content/html/content/src/nsHTMLSelectElement.cpp +++ b/content/html/content/src/nsHTMLSelectElement.cpp @@ -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 > &aElements, return nullptr; } -nsISupports* -nsHTMLOptionCollection::GetNamedItem(const nsAString& aName, - nsWrapperCache **aCache) -{ - nsINode *item = GetNamedItemHelper(mElements, aName); - *aCache = item; - return item; -} - nsINode* nsHTMLOptionCollection::GetParentObject() { diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp index 5144b568498..12d76cfdaca 100644 --- a/content/html/content/src/nsHTMLTableElement.cpp +++ b/content/html/content/src/nsHTMLTableElement.cpp @@ -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 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 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 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 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 diff --git a/content/html/content/src/nsHTMLTableRowElement.cpp b/content/html/content/src/nsHTMLTableRowElement.cpp index d7f80b34f37..3640e0d7a84 100644 --- a/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/content/html/content/src/nsHTMLTableRowElement.cpp @@ -144,11 +144,11 @@ nsHTMLTableRowElement::GetRowIndex(int32_t* aValue) nsCOMPtr rows; table->GetRows(getter_AddRefs(rows)); - uint32_t numRows; - rows->GetLength(&numRows); + nsCOMPtr 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 rows; section->GetRows(getter_AddRefs(rows)); - uint32_t numRows; - rows->GetLength(&numRows); + nsCOMPtr 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; } diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 769262fb95e..c5f75936663 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -1040,7 +1040,7 @@ nsHTMLDocument::GetBody() nsRefPtr 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; diff --git a/content/svg/content/src/DOMSVGLengthList.cpp b/content/svg/content/src/DOMSVGLengthList.cpp index 415e56ece9d..e1c11dd253a 100644 --- a/content/svg/content/src/DOMSVGLengthList.cpp +++ b/content/svg/content/src/DOMSVGLengthList.cpp @@ -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 diff --git a/content/svg/content/src/DOMSVGNumberList.cpp b/content/svg/content/src/DOMSVGNumberList.cpp index 7caaeecf70d..55622829c5d 100644 --- a/content/svg/content/src/DOMSVGNumberList.cpp +++ b/content/svg/content/src/DOMSVGNumberList.cpp @@ -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 diff --git a/content/svg/content/src/DOMSVGPathSegList.cpp b/content/svg/content/src/DOMSVGPathSegList.cpp index a104a44866a..66e58667af1 100644 --- a/content/svg/content/src/DOMSVGPathSegList.cpp +++ b/content/svg/content/src/DOMSVGPathSegList.cpp @@ -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 diff --git a/content/svg/content/src/DOMSVGPointList.cpp b/content/svg/content/src/DOMSVGPointList.cpp index a9686044dc2..7ab52c1b743 100644 --- a/content/svg/content/src/DOMSVGPointList.cpp +++ b/content/svg/content/src/DOMSVGPointList.cpp @@ -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 diff --git a/content/svg/content/src/DOMSVGTransformList.cpp b/content/svg/content/src/DOMSVGTransformList.cpp index 04d16b00c34..2a6871b57bd 100644 --- a/content/svg/content/src/DOMSVGTransformList.cpp +++ b/content/svg/content/src/DOMSVGTransformList.cpp @@ -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 diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp index a5200cf4184..e570fbb6021 100644 --- a/content/xbl/src/nsBindingManager.cpp +++ b/content/xbl/src/nsBindingManager.cpp @@ -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; diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 95abffcbc7f..888849084bd 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -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; diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index cb00fdbda5f..a37d50dbc63 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -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; } diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index 73a89e796de..9161a6951de 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -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(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(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 diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 88396a36997..8e254334b82 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -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 # #################################### diff --git a/dom/bindings/DOMJSProxyHandler.h b/dom/bindings/DOMJSProxyHandler.h index d575a4a4505..94e0954d784 100644 --- a/dom/bindings/DOMJSProxyHandler.h +++ b/dom/bindings/DOMJSProxyHandler.h @@ -25,11 +25,11 @@ enum { template struct Prefable; -class DOMProxyHandler : public DOMBaseProxyHandler +class DOMProxyHandler : public js::BaseProxyHandler { public: DOMProxyHandler(const DOMClass& aClass) - : DOMBaseProxyHandler(true), + : js::BaseProxyHandler(ProxyFamily()), mClass(aClass) { } diff --git a/dom/interfaces/base/nsIDOMClientRectList.idl b/dom/interfaces/base/nsIDOMClientRectList.idl index e50bb464fa9..b5ba809c0b3 100644 --- a/dom/interfaces/base/nsIDOMClientRectList.idl +++ b/dom/interfaces/base/nsIDOMClientRectList.idl @@ -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); }; diff --git a/dom/interfaces/core/nsIDOMDOMTokenList.idl b/dom/interfaces/core/nsIDOMDOMTokenList.idl index f0786d3d4cb..ac14acbd34f 100644 --- a/dom/interfaces/core/nsIDOMDOMTokenList.idl +++ b/dom/interfaces/core/nsIDOMDOMTokenList.idl @@ -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(); }; diff --git a/dom/interfaces/core/nsIDOMNodeList.idl b/dom/interfaces/core/nsIDOMNodeList.idl index c6585709583..ae553ef874c 100644 --- a/dom/interfaces/core/nsIDOMNodeList.idl +++ b/dom/interfaces/core/nsIDOMNodeList.idl @@ -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); }; diff --git a/dom/interfaces/events/nsIDOMPaintRequestList.idl b/dom/interfaces/events/nsIDOMPaintRequestList.idl index 5cd105398eb..df0dce556f9 100644 --- a/dom/interfaces/events/nsIDOMPaintRequestList.idl +++ b/dom/interfaces/events/nsIDOMPaintRequestList.idl @@ -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); }; diff --git a/dom/interfaces/html/nsIDOMHTMLCollection.idl b/dom/interfaces/html/nsIDOMHTMLCollection.idl index b3f8afef4fb..6cc989638ae 100644 --- a/dom/interfaces/html/nsIDOMHTMLCollection.idl +++ b/dom/interfaces/html/nsIDOMHTMLCollection.idl @@ -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); }; diff --git a/dom/interfaces/html/nsIDOMHTMLOptionsCollection.idl b/dom/interfaces/html/nsIDOMHTMLOptionsCollection.idl index 5e181021118..0edfd90fe98 100644 --- a/dom/interfaces/html/nsIDOMHTMLOptionsCollection.idl +++ b/dom/interfaces/html/nsIDOMHTMLOptionsCollection.idl @@ -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; diff --git a/dom/interfaces/html/nsIDOMHTMLPropertiesCollection.idl b/dom/interfaces/html/nsIDOMHTMLPropertiesCollection.idl index b5352ee28be..3d2a8e09996 100644 --- a/dom/interfaces/html/nsIDOMHTMLPropertiesCollection.idl +++ b/dom/interfaces/html/nsIDOMHTMLPropertiesCollection.idl @@ -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); }; diff --git a/dom/interfaces/html/nsIDOMPropertyNodeList.idl b/dom/interfaces/html/nsIDOMPropertyNodeList.idl index 2b69cc1f3b0..6a25359f2ff 100644 --- a/dom/interfaces/html/nsIDOMPropertyNodeList.idl +++ b/dom/interfaces/html/nsIDOMPropertyNodeList.idl @@ -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(); }; diff --git a/dom/interfaces/svg/nsIDOMSVGLengthList.idl b/dom/interfaces/svg/nsIDOMSVGLengthList.idl index 52e28ca163f..14693ac8aac 100644 --- a/dom/interfaces/svg/nsIDOMSVGLengthList.idl +++ b/dom/interfaces/svg/nsIDOMSVGLengthList.idl @@ -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); diff --git a/dom/interfaces/svg/nsIDOMSVGNumberList.idl b/dom/interfaces/svg/nsIDOMSVGNumberList.idl index 431266c1099..588fbc2dca5 100644 --- a/dom/interfaces/svg/nsIDOMSVGNumberList.idl +++ b/dom/interfaces/svg/nsIDOMSVGNumberList.idl @@ -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); diff --git a/dom/interfaces/svg/nsIDOMSVGPathSegList.idl b/dom/interfaces/svg/nsIDOMSVGPathSegList.idl index 0f6c8e82aed..694960c1fdb 100644 --- a/dom/interfaces/svg/nsIDOMSVGPathSegList.idl +++ b/dom/interfaces/svg/nsIDOMSVGPathSegList.idl @@ -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); diff --git a/dom/interfaces/svg/nsIDOMSVGPointList.idl b/dom/interfaces/svg/nsIDOMSVGPointList.idl index 276faee49f7..5f73ab11b01 100644 --- a/dom/interfaces/svg/nsIDOMSVGPointList.idl +++ b/dom/interfaces/svg/nsIDOMSVGPointList.idl @@ -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); diff --git a/dom/interfaces/svg/nsIDOMSVGTransformList.idl b/dom/interfaces/svg/nsIDOMSVGTransformList.idl index 413c164b886..d0e677a2321 100644 --- a/dom/interfaces/svg/nsIDOMSVGTransformList.idl +++ b/dom/interfaces/svg/nsIDOMSVGTransformList.idl @@ -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 ); diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index 1a02ee12852..691ea15679c 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -260,17 +260,19 @@ nsPlaintextEditor::UpdateMetaCharset(nsIDOMDocument* aDocument, { MOZ_ASSERT(aDocument); // get a list of META tags - nsCOMPtr metaList; + nsCOMPtr 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 metaList = do_QueryInterface(list); uint32_t listLength = 0; metaList->GetLength(&listLength); for (uint32_t i = 0; i < listLength; ++i) { - nsCOMPtr metaNode = metaList->GetNodeAt(i); + nsCOMPtr metaNode = metaList->Item(i); MOZ_ASSERT(metaNode); if (!metaNode->IsElement()) { diff --git a/js/xpconnect/src/Makefile.in b/js/xpconnect/src/Makefile.in index 601b74d6173..f29f5d48980 100644 --- a/js/xpconnect/src/Makefile.in +++ b/js/xpconnect/src/Makefile.in @@ -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 \ diff --git a/js/xpconnect/src/XPCConvert.cpp b/js/xpconnect/src/XPCConvert.cpp index 56d8ca67c1a..2bcb3557612 100644 --- a/js/xpconnect/src/XPCConvert.cpp +++ b/js/xpconnect/src/XPCConvert.cpp @@ -18,7 +18,6 @@ #include "AccessCheck.h" #include "nsJSUtils.h" -#include "dombindings.h" #include "nsWrapperCacheInlines.h" #include "jsapi.h" diff --git a/js/xpconnect/src/XPCJSID.cpp b/js/xpconnect/src/XPCJSID.cpp index 276b9e41ac1..9f5a79d96f7 100644 --- a/js/xpconnect/src/XPCJSID.cpp +++ b/js/xpconnect/src/XPCJSID.cpp @@ -482,14 +482,7 @@ nsJSIID::HasInstance(nsIXPConnectWrappedNative *wrapper, } nsISupports *identity; - if (mozilla::dom::oldproxybindings::instanceIsProxy(obj)) { - identity = - static_cast(js::GetProxyPrivate(obj).toPrivate()); - } else if (!mozilla::dom::UnwrapDOMObjectToISupports(obj, identity)) { - identity = nullptr; - } - - if (identity) { + if (mozilla::dom::UnwrapDOMObjectToISupports(obj, identity)) { nsCOMPtr ci = do_QueryInterface(identity); XPCCallContext ccx(JS_CALLER, cx); diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index c3423330287..b352a0f013e 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -417,16 +417,10 @@ SuspectDOMExpandos(nsPtrHashKey *key, void *arg) { Closure *closure = static_cast(arg); JSObject* obj = key->GetKey(); - nsISupports* native = nullptr; - if (dom::oldproxybindings::instanceIsProxy(obj)) { - native = static_cast(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(obj, slot); - } + const dom::DOMClass* clasp; + dom::DOMObjectSlot slot = GetDOMClass(obj, clasp); + MOZ_ASSERT(slot != dom::eNonDOMObject && clasp->mDOMObjectIsISupports); + nsISupports* native = dom::UnwrapDOMObject(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) diff --git a/js/xpconnect/src/XPCWrappedNative.cpp b/js/xpconnect/src/XPCWrappedNative.cpp index 0540d46ee37..be45deda9f5 100644 --- a/js/xpconnect/src/XPCWrappedNative.cpp +++ b/js/xpconnect/src/XPCWrappedNative.cpp @@ -18,7 +18,6 @@ #include "AccessCheck.h" #include "WrapperFactory.h" #include "XrayWrapper.h" -#include "dombindings.h" #include "nsContentUtils.h" diff --git a/js/xpconnect/src/codegen.py b/js/xpconnect/src/codegen.py deleted file mode 100644 index 63c001aaedc..00000000000 --- a/js/xpconnect/src/codegen.py +++ /dev/null @@ -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 ${name}(already_AddRefed(" - "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) diff --git a/js/xpconnect/src/dictionary_helper_gen.py b/js/xpconnect/src/dictionary_helper_gen.py index 5c4db7ce294..7c8e844cd37 100644 --- a/js/xpconnect/src/dictionary_helper_gen.py +++ b/js/xpconnect/src/dictionary_helper_gen.py @@ -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') diff --git a/js/xpconnect/src/dombindings.conf b/js/xpconnect/src/dombindings.conf deleted file mode 100644 index f53b1494fc7..00000000000 --- a/js/xpconnect/src/dombindings.conf +++ /dev/null @@ -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', - } diff --git a/js/xpconnect/src/dombindings.cpp b/js/xpconnect/src/dombindings.cpp deleted file mode 100644 index d85edc03f0b..00000000000 --- a/js/xpconnect/src/dombindings.cpp +++ /dev/null @@ -1,1032 +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/. */ - -#include "mozilla/Util.h" - -#include "dombindings.h" -#include "xpcpublic.h" -#include "xpcprivate.h" -#include "XPCQuickStubs.h" -#include "XPCWrapper.h" -#include "WrapperFactory.h" -#include "nsDOMClassInfo.h" -#include "nsGlobalWindow.h" -#include "nsWrapperCacheInlines.h" -#include "mozilla/dom/BindingUtils.h" - -#include "jsapi.h" - -using namespace JS; -using namespace mozilla::dom; - -namespace mozilla { -namespace dom { -namespace oldproxybindings { - -enum { - JSPROXYSLOT_EXPANDO = 0, - JSPROXYSLOT_XRAY_EXPANDO -}; - -static jsid s_prototype_id = JSID_VOID; - -static jsid s_length_id = JSID_VOID; - -static jsid s_iterator_id = JSID_VOID; - -bool -DefineStaticJSVal(JSContext *cx, jsid &id, const char *string) -{ - if (JSString *str = ::JS_InternString(cx, string)) { - id = INTERNED_STRING_TO_JSID(cx, str); - return true; - } - return false; -} - -#define SET_JSID_TO_STRING(_cx, _string) \ - DefineStaticJSVal(_cx, s_##_string##_id, #_string) - -bool -DefineStaticJSVals(JSContext *cx) -{ - JSAutoRequest ar(cx); - - return SET_JSID_TO_STRING(cx, prototype) && - SET_JSID_TO_STRING(cx, length) && - SET_JSID_TO_STRING(cx, iterator) && - DefinePropertyStaticJSVals(cx); -} - - -JSBool -Throw(JSContext *cx, nsresult rv) -{ - XPCThrower::Throw(rv, cx); - return false; -} - -template -static bool -Wrap(JSContext *cx, JSObject *scope, T *p, nsWrapperCache *cache, jsval *vp) -{ - if (xpc_FastGetCachedWrapper(cache, scope, vp)) - return true; - qsObjectHelper helper(p, cache); - return XPCOMObjectToJsval(cx, scope, helper, NULL, true, vp); -} - -template -static inline bool -Wrap(JSContext *cx, JSObject *scope, T *p, jsval *vp) -{ - return Wrap(cx, scope, p, GetWrapperCache(p), vp); -} - -template<> -inline bool -Wrap(JSContext *cx, JSObject *scope, NoType *p, jsval *vp) -{ - NS_RUNTIMEABORT("We try to wrap the result from calling a noop?"); - return false; -} - -template -inline bool -Wrap(JSContext *cx, JSObject *scope, nsCOMPtr &p, jsval *vp) -{ - return Wrap(cx, scope, p.get(), vp); -} - -static inline bool -Wrap(JSContext *cx, JSObject *scope, nsISupportsResult &result, jsval *vp) -{ - return Wrap(cx, scope, result.mResult, result.mCache, vp); -} - -static inline bool -Wrap(JSContext *cx, JSObject *scope, nsString &result, jsval *vp) -{ - return xpc::StringToJsval(cx, result, vp); -} - -template -bool -Unwrap(JSContext *cx, jsval v, T **ppArg, nsISupports **ppArgRef, jsval *vp) -{ - nsresult rv = xpc_qsUnwrapArg(cx, v, ppArg, ppArgRef, vp); - if (NS_FAILED(rv)) - return Throw(cx, rv); - return true; -} - -template<> -bool -Unwrap(JSContext *cx, jsval v, NoType **ppArg, nsISupports **ppArgRef, jsval *vp) -{ - NS_RUNTIMEABORT("We try to unwrap an argument for a noop?"); - return false; -} - -template -typename ListBase::Properties ListBase::sProtoProperties[] = { - { JSID_VOID, NULL, NULL } -}; -template -size_t ListBase::sProtoPropertiesCount = 0; - -template -typename ListBase::Methods ListBase::sProtoMethods[] = { - { JSID_VOID, NULL, 0 } -}; -template -size_t ListBase::sProtoMethodsCount = 0; - -template -ListBase ListBase::instance; - -template -typename ListBase::ListType* -ListBase::getNative(JSObject *obj) -{ - return static_cast(js::GetProxyPrivate(obj).toPrivate()); -} - -template -typename ListBase::ListType* -ListBase::getListObject(JSObject *obj) -{ - if (xpc::WrapperFactory::IsXrayWrapper(obj)) - obj = js::UnwrapObject(obj); - MOZ_ASSERT(objIsList(obj)); - return getNative(obj); -} - -static JSBool -UnwrapSecurityWrapper(JSContext *cx, JSObject *obj, JSObject *callee, JSObject **unwrapped) -{ - MOZ_ASSERT(XPCWrapper::IsSecurityWrapper(obj)); - - if (callee && JS_GetGlobalForObject(cx, obj) == JS_GetGlobalForObject(cx, callee)) { - *unwrapped = js::UnwrapObject(obj); - } else { - *unwrapped = XPCWrapper::Unwrap(cx, obj); - if (!*unwrapped) - return Throw(cx, NS_ERROR_XPC_SECURITY_MANAGER_VETO); - } - return true; -} - -template -bool -ListBase::instanceIsListObject(JSContext *cx, JSObject *obj, JSObject *callee) -{ - if (XPCWrapper::IsSecurityWrapper(obj) && !UnwrapSecurityWrapper(cx, obj, callee, &obj)) - return false; - - if (!objIsList(obj)) { - // FIXME: Throw a proper DOM exception. - JS_ReportError(cx, "type error: wrong object"); - return false; - } - return true; -} - -template -JSBool -ListBase::length_getter(JSContext *cx, JSHandleObject obj, JSHandleId id, JSMutableHandleValue vp) -{ - if (!instanceIsListObject(cx, obj, NULL)) - return false; - uint32_t length; - getListObject(obj)->GetLength(&length); - MOZ_ASSERT(int32_t(length) >= 0); - vp.set(UINT_TO_JSVAL(length)); - return true; -} - -template -bool -ListBase::getItemAt(ListType *list, uint32_t i, IndexGetterType &item) -{ - JS_STATIC_ASSERT(!hasIndexGetter); - return false; -} - -template -bool -ListBase::setItemAt(JSContext *cx, ListType *list, uint32_t i, IndexSetterType item) -{ - JS_STATIC_ASSERT(!hasIndexSetter); - return false; -} - -template -bool -ListBase::getNamedItem(ListType *list, const nsAString& aName, NameGetterType &item) -{ - JS_STATIC_ASSERT(!hasNameGetter); - return false; -} - -template -bool -ListBase::setNamedItem(JSContext *cx, ListType *list, const nsAString& aName, - NameSetterType item) -{ - JS_STATIC_ASSERT(!hasNameSetter); - return false; -} - -template -bool -ListBase::namedItem(JSContext *cx, JSObject *obj, jsval *name, NameGetterType &result, - bool *hasResult) -{ - xpc_qsDOMString nameString(cx, *name, name, - xpc_qsDOMString::eDefaultNullBehavior, - xpc_qsDOMString::eDefaultUndefinedBehavior); - if (!nameString.IsValid()) - return false; - *hasResult = getNamedItem(getListObject(obj), nameString, result); - return true; -} - -JSBool -interface_hasInstance(JSContext *cx, JSHandleObject obj, JSMutableHandleValue vp, JSBool *bp) -{ - if (vp.isObject()) { - jsval prototype; - if (!JS_GetPropertyById(cx, obj, s_prototype_id, &prototype) || - JSVAL_IS_PRIMITIVE(prototype)) { - JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL, - JSMSG_THROW_TYPE_ERROR); - return false; - } - - JSObject *other = &vp.toObject(); - if (instanceIsProxy(other)) { - ProxyHandler *handler = static_cast(js::GetProxyHandler(other)); - if (handler->isInstanceOf(JSVAL_TO_OBJECT(prototype))) { - *bp = true; - } else { - JSObject *protoObj = JSVAL_TO_OBJECT(prototype); - JSObject *proto = other; - for (;;) { - if (!JS_GetPrototype(cx, proto, &proto)) - return false; - if (!proto) - break; - if (proto == protoObj) { - *bp = true; - return true; - } - } - *bp = false; - } - - return true; - } - } - - *bp = false; - return true; -} - -js::Class sInterfacePrototypeClass = { - "Object", - JSCLASS_HAS_RESERVED_SLOTS(0), - JS_PropertyStub, /* addProperty */ - JS_PropertyStub, /* delProperty */ - JS_PropertyStub, /* getProperty */ - JS_StrictPropertyStub, /* setProperty */ - JS_EnumerateStub, - JS_ResolveStub, - JS_ConvertStub -}; - -template -JSObject * -ListBase::getPrototype(JSContext *cx, JSObject *receiver) -{ - XPCWrappedNativeScope *scope = - XPCWrappedNativeScope::FindInJSObjectScope(cx, receiver); - if (!scope) - return NULL; - - return getPrototype(cx, scope, receiver); -} - -template -JSObject * -ListBase::getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, - JSObject *receiver) -{ - nsDataHashtable &cache = - scope->GetCachedDOMPrototypes(); - - JSObject *interfacePrototype; - if (cache.IsInitialized()) { - if (cache.Get(sInterfaceClass.name, &interfacePrototype)) { - xpc_UnmarkGrayObject(interfacePrototype); - return interfacePrototype; - } - } else { - cache.Init(); - } - - JSObject* proto = Base::getPrototype(cx, scope, receiver); - if (!proto) - return NULL; - - JSObject *global = scope->GetGlobalJSObject(); - interfacePrototype = JS_NewObject(cx, Jsvalify(&sInterfacePrototypeClass), proto, global); - if (!interfacePrototype) - return NULL; - - for (size_t n = 0; n < sProtoPropertiesCount; ++n) { - MOZ_ASSERT(sProtoProperties[n].getter); - jsid id = sProtoProperties[n].id; - unsigned attrs = JSPROP_ENUMERATE | JSPROP_SHARED; - if (!sProtoProperties[n].setter) - attrs |= JSPROP_READONLY; - if (!JS_DefinePropertyById(cx, interfacePrototype, id, JSVAL_VOID, - sProtoProperties[n].getter, sProtoProperties[n].setter, attrs)) - return NULL; - } - - for (size_t n = 0; n < sProtoMethodsCount; ++n) { - jsid id = sProtoMethods[n].id; - JSFunction *fun = JS_NewFunctionById(cx, sProtoMethods[n].native, sProtoMethods[n].nargs, - 0, js::GetObjectParent(interfacePrototype), id); - if (!fun) - return NULL; - JSObject *funobj = JS_GetFunctionObject(fun); - if (!JS_DefinePropertyById(cx, interfacePrototype, id, OBJECT_TO_JSVAL(funobj), - NULL, NULL, JSPROP_ENUMERATE)) - return NULL; - } - - JSObject *interface = JS_NewObject(cx, Jsvalify(&sInterfaceClass), NULL, global); - if (!interface) - return NULL; - - if (!JS_LinkConstructorAndPrototype(cx, interface, interfacePrototype)) - return NULL; - - if (!JS_DefineProperty(cx, receiver, sInterfaceClass.name, OBJECT_TO_JSVAL(interface), NULL, - NULL, 0)) - return NULL; - - if (!cache.Put(sInterfaceClass.name, interfacePrototype, fallible_t())) - return NULL; - - return interfacePrototype; -} - -template -JSObject * -ListBase::create(JSContext *cx, JSObject *scope, ListType *aList, - nsWrapperCache* aWrapperCache) -{ - JSObject *parent = WrapNativeParent(cx, scope, aList->GetParentObject()); - if (!parent) - return NULL; - - JSObject *global = js::GetGlobalForObjectCrossCompartment(parent); - JSAutoCompartment ac(cx, global); - - JSObject *proto = getPrototype(cx, global); - if (!proto) - return NULL; - JSObject *obj = NewProxyObject(cx, &ListBase::instance, - PrivateValue(aList), proto, parent); - if (!obj) - return NULL; - - NS_ADDREF(aList); - - aWrapperCache->SetWrapper(obj); - - return obj; -} - -static JSObject * -getExpandoObject(JSObject *obj) -{ - NS_ASSERTION(instanceIsProxy(obj), "expected a DOM proxy object"); - Value v = js::GetProxyExtra(obj, JSPROXYSLOT_EXPANDO); - return v.isUndefined() ? NULL : v.toObjectOrNull(); -} - -static int32_t -IdToInt32(JSContext *cx, jsid id) -{ - JSAutoRequest ar(cx); - - jsval idval; - double array_index; - int32_t i; - if (!::JS_IdToValue(cx, id, &idval) || - !::JS_ValueToNumber(cx, idval, &array_index) || - !::JS_DoubleIsInt32(array_index, &i)) { - return -1; - } - - return i; -} - -static inline int32_t -GetArrayIndexFromId(JSContext *cx, jsid id) -{ - if (NS_LIKELY(JSID_IS_INT(id))) - return JSID_TO_INT(id); - if (NS_LIKELY(id == s_length_id)) - return -1; - if (NS_LIKELY(JSID_IS_ATOM(id))) { - JSAtom *atom = JSID_TO_ATOM(id); - jschar s = *js::GetAtomChars(atom); - if (NS_LIKELY((unsigned)s >= 'a' && (unsigned)s <= 'z')) - return -1; - - uint32_t i; - JSLinearString *str = js::AtomToLinearString(JSID_TO_ATOM(id)); - return js::StringIsArrayIndex(str, &i) ? i : -1; - } - return IdToInt32(cx, id); -} - -static void -FillPropertyDescriptor(JSPropertyDescriptor *desc, JSObject *obj, jsval v, bool readonly) -{ - desc->obj = obj; - desc->value = v; - desc->attrs = (readonly ? JSPROP_READONLY : 0) | JSPROP_ENUMERATE; - desc->getter = NULL; - desc->setter = NULL; - desc->shortid = 0; -} - -template -bool -ListBase::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, - JSPropertyDescriptor *desc) -{ - if (set) { - if (hasIndexSetter) { - int32_t index = GetArrayIndexFromId(cx, id); - if (index >= 0) { - FillPropertyDescriptor(desc, proxy, JSVAL_VOID, false); - return true; - } - } - - if (hasNameSetter && JSID_IS_STRING(id)) { - FillPropertyDescriptor(desc, proxy, JSVAL_VOID, false); - return true; - } - } else { - if (hasIndexGetter) { - int32_t index = GetArrayIndexFromId(cx, id); - if (index >= 0) { - IndexGetterType result; - if (!getItemAt(getListObject(proxy), uint32_t(index), result)) - return true; - - jsval v; - if (!Wrap(cx, proxy, result, &v)) - return false; - FillPropertyDescriptor(desc, proxy, v, !hasIndexSetter); - return true; - } - } - } - - JSObject *expando; - if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = getExpandoObject(proxy))) { - unsigned flags = (set ? JSRESOLVE_ASSIGNING : 0) | JSRESOLVE_QUALIFIED; - if (!JS_GetPropertyDescriptorById(cx, expando, id, flags, desc)) - return false; - if (desc->obj) { - // Pretend the property lives on the wrapper. - desc->obj = proxy; - return true; - } - } - - if (hasNameGetter && !set && JSID_IS_STRING(id) && !hasPropertyOnPrototype(cx, proxy, id)) { - jsval name = STRING_TO_JSVAL(JSID_TO_STRING(id)); - bool hasResult; - NameGetterType result; - if (!namedItem(cx, proxy, &name, result, &hasResult)) - return false; - if (hasResult) { - jsval v; - if (!Wrap(cx, proxy, result, &v)) - return false; - FillPropertyDescriptor(desc, proxy, v, !hasNameSetter); - return true; - } - } - - desc->obj = NULL; - return true; -} - -template -bool -ListBase::getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, - JSPropertyDescriptor *desc) -{ - if (!getOwnPropertyDescriptor(cx, proxy, id, set, desc)) - return false; - if (desc->obj) - return true; - if (xpc::WrapperFactory::IsXrayWrapper(proxy)) - return resolveNativeName(cx, proxy, id, desc); - JSObject *proto; - if (!js::GetObjectProto(cx, proxy, &proto)) - return false; - if (!proto) { - desc->obj = NULL; - return true; - } - return JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, desc); -} - -JSClass ExpandoClass = { - "DOM proxy binding expando object", - JSCLASS_HAS_PRIVATE, - JS_PropertyStub, - JS_PropertyStub, - JS_PropertyStub, - JS_StrictPropertyStub, - JS_EnumerateStub, - JS_ResolveStub, - JS_ConvertStub -}; - -template -JSObject * -ListBase::ensureExpandoObject(JSContext *cx, JSObject *obj) -{ - NS_ASSERTION(instanceIsProxy(obj), "expected a DOM proxy object"); - JSObject *expando = getExpandoObject(obj); - if (!expando) { - expando = JS_NewObjectWithGivenProto(cx, &ExpandoClass, nullptr, - js::GetObjectParent(obj)); - if (!expando) - return NULL; - - JSCompartment *compartment = js::GetObjectCompartment(obj); - xpc::CompartmentPrivate *priv = xpc::GetCompartmentPrivate(compartment); - if (!priv->RegisterDOMExpandoObject(obj)) - return NULL; - - nsWrapperCache* cache; - CallQueryInterface(getListObject(obj), &cache); - cache->SetPreservingWrapper(true); - - js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando)); - JS_SetPrivate(expando, js::GetProxyPrivate(obj).toPrivate()); - } - return expando; -} - -template -bool -ListBase::defineProperty(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc) -{ - if (hasIndexSetter) { - int32_t index = GetArrayIndexFromId(cx, id); - if (index >= 0) { - nsCOMPtr ref; - IndexSetterType value; - jsval v; - return Unwrap(cx, desc->value, &value, getter_AddRefs(ref), &v) && - setItemAt(cx, getListObject(proxy), index, value); - } - } - - if (hasNameSetter && JSID_IS_STRING(id)) { - jsval name = STRING_TO_JSVAL(JSID_TO_STRING(id)); - xpc_qsDOMString nameString(cx, name, &name, - xpc_qsDOMString::eDefaultNullBehavior, - xpc_qsDOMString::eDefaultUndefinedBehavior); - if (!nameString.IsValid()) - return false; - - nsCOMPtr ref; - NameSetterType value; - jsval v; - if (!Unwrap(cx, desc->value, &value, getter_AddRefs(ref), &v)) - return false; - return setNamedItem(cx, getListObject(proxy), nameString, value); - } - - if (xpc::WrapperFactory::IsXrayWrapper(proxy)) - return true; - - JSObject *expando = ensureExpandoObject(cx, proxy); - if (!expando) - return false; - - return JS_DefinePropertyById(cx, expando, id, desc->value, desc->getter, desc->setter, - desc->attrs); -} - -template -bool -ListBase::getOwnPropertyNames(JSContext *cx, JSObject *proxy, AutoIdVector &props) -{ - uint32_t length; - getListObject(proxy)->GetLength(&length); - MOZ_ASSERT(int32_t(length) >= 0); - for (int32_t i = 0; i < int32_t(length); ++i) { - if (!props.append(INT_TO_JSID(i))) - return false; - } - - JSObject *expando; - if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = getExpandoObject(proxy)) && - !js::GetPropertyNames(cx, expando, JSITER_OWNONLY | JSITER_HIDDEN, &props)) - return false; - - // FIXME: Add named items - return true; -} - -template -bool -ListBase::delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) -{ - JSBool b = true; - - JSObject *expando; - if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = getExpandoObject(proxy))) { - jsval v; - if (!JS_DeletePropertyById2(cx, expando, id, &v) || - !JS_ValueToBoolean(cx, v, &b)) { - return false; - } - } - - *bp = !!b; - return true; -} - -template -bool -ListBase::enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props) -{ - JSObject *proto; - return JS_GetPrototype(cx, proxy, &proto) && - getOwnPropertyNames(cx, proxy, props) && - (!proto || js::GetPropertyNames(cx, proto, 0, &props)); -} - -template -bool -ListBase::hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp) -{ - if (hasIndexGetter) { - int32_t index = GetArrayIndexFromId(cx, id); - if (index >= 0) { - IndexGetterType result; - *bp = getItemAt(getListObject(proxy), uint32_t(index), result); - return true; - } - } - - JSObject *expando = getExpandoObject(proxy); - if (expando) { - JSBool b = true; - JSBool ok = JS_HasPropertyById(cx, expando, id, &b); - *bp = !!b; - if (!ok || *bp) - return ok; - } - - if (hasNameGetter && JSID_IS_STRING(id) && !hasPropertyOnPrototype(cx, proxy, id)) { - jsval name = STRING_TO_JSVAL(JSID_TO_STRING(id)); - NameGetterType result; - return namedItem(cx, proxy, &name, result, bp); - } - - *bp = false; - return true; -} - -template -bool -ListBase::has(JSContext *cx, JSObject *proxy, jsid id, bool *bp) -{ - if (!hasOwn(cx, proxy, id, bp)) - return false; - // We have the property ourselves; no need to worry about our - // prototype chain. - if (*bp) - return true; - - // OK, now we have to look at the proto - JSObject *proto; - if (!js::GetObjectProto(cx, proxy, &proto)) - return false; - if (!proto) - return true; - - JSBool protoHasProp; - bool ok = JS_HasPropertyById(cx, proto, id, &protoHasProp); - if (ok) - *bp = protoHasProp; - return ok; -} - -template -bool -ListBase::resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc) -{ - MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(proxy)); - - for (size_t n = 0; n < sProtoPropertiesCount; ++n) { - if (id == sProtoProperties[n].id) { - desc->attrs = JSPROP_ENUMERATE | JSPROP_SHARED; - if (!sProtoProperties[n].setter) - desc->attrs |= JSPROP_READONLY; - desc->obj = proxy; - desc->setter = sProtoProperties[n].setter; - desc->getter = sProtoProperties[n].getter; - return true; - } - } - - for (size_t n = 0; n < sProtoMethodsCount; ++n) { - if (id == sProtoMethods[n].id) { - JSFunction *fun = JS_NewFunctionById(cx, sProtoMethods[n].native, - sProtoMethods[n].nargs, 0, proxy, id); - if (!fun) - return false; - JSObject *funobj = JS_GetFunctionObject(fun); - desc->value.setObject(*funobj); - desc->attrs = JSPROP_ENUMERATE; - desc->obj = proxy; - desc->setter = nullptr; - desc->getter = nullptr; - return true; - } - } - - return Base::resolveNativeName(cx, proxy, id, desc); -} - -template -bool -ListBase::getPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id, bool *found, - JS::Value *vp) -{ - JSObject *proto; - if (!js::GetObjectProto(cx, proxy, &proto)) - return false; - if (!proto) - return true; - - JSBool hasProp; - if (!JS_HasPropertyById(cx, proto, id, &hasProp)) - return false; - - *found = hasProp; - if (!hasProp || !vp) - return true; - - return JS_ForwardGetPropertyTo(cx, proto, id, proxy, vp); -} - -template -bool -ListBase::hasPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id) -{ - Maybe ac; - if (xpc::WrapperFactory::IsXrayWrapper(proxy)) { - proxy = js::UnwrapObject(proxy); - ac.construct(cx, proxy); - } - MOZ_ASSERT(objIsList(proxy)); - - bool found = false; - // We ignore an error from getPropertyOnPrototype. - return !getPropertyOnPrototype(cx, proxy, id, &found, NULL) || found; -} - -template -bool -ListBase::get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp) -{ - NS_ASSERTION(!xpc::WrapperFactory::IsXrayWrapper(proxy), - "Should not have a XrayWrapper here"); - - bool getFromExpandoObject = true; - - if (hasIndexGetter) { - int32_t index = GetArrayIndexFromId(cx, id); - if (index >= 0) { - IndexGetterType result; - if (getItemAt(getListObject(proxy), uint32_t(index), result)) - return Wrap(cx, proxy, result, vp); - - // Even if we don't have this index, we don't forward the - // get on to our expando object. - getFromExpandoObject = false; - } - } - - if (getFromExpandoObject) { - JSObject *expando = getExpandoObject(proxy); - if (expando) { - JSBool hasProp; - if (!JS_HasPropertyById(cx, expando, id, &hasProp)) - return false; - - if (hasProp) - return JS_GetPropertyById(cx, expando, id, vp); - } - } - - bool found = false; - if (!getPropertyOnPrototype(cx, proxy, id, &found, vp)) - return false; - - if (found) - return true; - - if (hasNameGetter && JSID_IS_STRING(id)) { - jsval name = STRING_TO_JSVAL(JSID_TO_STRING(id)); - bool hasResult; - NameGetterType result; - if (!namedItem(cx, proxy, &name, result, &hasResult)) - return false; - if (hasResult) - return Wrap(cx, proxy, result, vp); - } - - vp->setUndefined(); - return true; -} - -template -bool -ListBase::getElementIfPresent(JSContext *cx, JSObject *proxy, JSObject *receiver, - uint32_t index, Value *vp, bool *present) -{ - NS_ASSERTION(!xpc::WrapperFactory::IsXrayWrapper(proxy), - "Should not have a XrayWrapper here"); - - if (hasIndexGetter) { - IndexGetterType result; - *present = getItemAt(getListObject(proxy), index, result); - if (*present) - return Wrap(cx, proxy, result, vp); - } - - jsid id; - if (!JS_IndexToId(cx, index, &id)) - return false; - - // if hasIndexGetter, we skip the expando object - if (!hasIndexGetter) { - JSObject *expando = getExpandoObject(proxy); - if (expando) { - JSBool isPresent; - if (!JS_GetElementIfPresent(cx, expando, index, expando, vp, &isPresent)) - return false; - if (isPresent) { - *present = true; - return true; - } - } - } - - // No need to worry about name getters here, so just check the proto. - - JSObject *proto; - if (!js::GetObjectProto(cx, proxy, &proto)) - return false; - if (proto) { - JSBool isPresent; - if (!JS_GetElementIfPresent(cx, proto, index, proxy, vp, &isPresent)) - return false; - *present = isPresent; - return true; - } - - *present = false; - // Can't Debug_SetValueRangeToCrashOnTouch because it's not public - return true; -} - -template -bool -ListBase::set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict, - Value *vp) -{ - return ProxyHandler::set(cx, proxy, proxy, id, strict, vp); -} - -template -bool -ListBase::keys(JSContext *cx, JSObject *proxy, AutoIdVector &props) -{ - return ProxyHandler::keys(cx, proxy, props); -} - -template -bool -ListBase::iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp) -{ - return ProxyHandler::iterate(cx, proxy, flags, vp); -} - -template -bool -ListBase::hasInstance(JSContext *cx, JS::HandleObject proxy, JS::MutableHandleValue vp, - bool *bp) -{ - *bp = vp.isObject() && js::GetObjectClass(&vp.toObject()) == &sInterfaceClass; - return true; -} - -template -JSString * -ListBase::obj_toString(JSContext *cx, JSObject *proxy) -{ - const char *clazz = sInterfaceClass.name; - size_t nchars = 9 + strlen(clazz); /* 9 for "[object ]" */ - jschar *chars = (jschar *)JS_malloc(cx, (nchars + 1) * sizeof(jschar)); - if (!chars) - return NULL; - - const char *prefix = "[object "; - nchars = 0; - while ((chars[nchars] = (jschar)*prefix) != 0) - nchars++, prefix++; - while ((chars[nchars] = (jschar)*clazz) != 0) - nchars++, clazz++; - chars[nchars++] = ']'; - chars[nchars] = 0; - - JSString *str = JS_NewUCString(cx, chars, nchars); - if (!str) - JS_free(cx, chars); - return str; -} - -template -void -ListBase::finalize(JSFreeOp *fop, JSObject *proxy) -{ - ListType *list = getListObject(proxy); - nsWrapperCache *cache; - CallQueryInterface(list, &cache); - if (cache) { - cache->ClearWrapper(); - } - XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance(); - if (rt) { - rt->DeferredRelease(nativeToSupports(list)); - } - else { - NS_RELEASE(list); - } -} - - -JSObject* -NoBase::getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, JSObject *receiver) -{ - // We need to pass the object prototype to JS_NewObject. If we pass NULL then the JS engine - // will look up a prototype on the global by using the class' name and we'll recurse into - // getPrototype. - return JS_GetObjectPrototype(cx, receiver); -} - -JSObject* -GetXrayExpandoChain(JSObject *obj) { - MOZ_ASSERT(instanceIsProxy(obj)); - js::Value v = js::GetProxyExtra(obj, JSPROXYSLOT_XRAY_EXPANDO); - return v.isUndefined() ? nullptr : &v.toObject(); -} - -void -SetXrayExpandoChain(JSObject *obj, JSObject *chain) { - MOZ_ASSERT(instanceIsProxy(obj)); - js::Value v = chain ? JS::ObjectValue(*chain) : JSVAL_VOID; - js::SetProxyExtra(obj, JSPROXYSLOT_XRAY_EXPANDO, v); -} - -} -} -} -#include "dombindings_gen.cpp" diff --git a/js/xpconnect/src/dombindings.h b/js/xpconnect/src/dombindings.h deleted file mode 100644 index 38e074e78f3..00000000000 --- a/js/xpconnect/src/dombindings.h +++ /dev/null @@ -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 -class Op { -public: - typedef Type T; - enum { - hasOp = 1 - }; -}; - -template -class Getter : public Op -{ -}; - -template -class Setter : public Op -{ -}; - -template -class Ops -{ -public: - typedef Getter G; - typedef Setter S; -}; - -typedef Ops NoOps; - -template -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 ListClass : public DerivedListClass { -}; - -template -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 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 */ diff --git a/js/xpconnect/src/dombindingsgen.py b/js/xpconnect/src/dombindingsgen.py deleted file mode 100644 index bda03c1cdcc..00000000000 --- a/js/xpconnect/src/dombindingsgen.py +++ /dev/null @@ -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\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() diff --git a/js/xpconnect/src/event_impl_gen.py b/js/xpconnect/src/event_impl_gen.py index 5f89ec903f6..540474c43fe 100644 --- a/js/xpconnect/src/event_impl_gen.py +++ b/js/xpconnect/src/event_impl_gen.py @@ -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') diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index feaf1bc8853..272b3c942fc 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -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(xpc_GetJSPrivate(obj))); - } else if (oldproxybindings::instanceIsProxy(obj)) { - NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "js::GetProxyPrivate(obj)"); - nsISupports *identity = - static_cast(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(js::GetProxyPrivate(aJSObj).toPrivate()); - nsCOMPtr 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 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; } diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index 1495dff3022..1293756e774 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -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(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 diff --git a/js/xpconnect/tests/chrome/test_nodelists.xul b/js/xpconnect/tests/chrome/test_nodelists.xul index 92ba3192a86..7c4d5f44ce6 100644 --- a/js/xpconnect/tests/chrome/test_nodelists.xul +++ b/js/xpconnect/tests/chrome/test_nodelists.xul @@ -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(); } diff --git a/js/xpconnect/wrappers/FilteringWrapper.cpp b/js/xpconnect/wrappers/FilteringWrapper.cpp index 143fd4eeeb3..9d84db8f123 100644 --- a/js/xpconnect/wrappers/FilteringWrapper.cpp +++ b/js/xpconnect/wrappers/FilteringWrapper.cpp @@ -107,8 +107,6 @@ FilteringWrapper::enter(JSContext *cx, JSObject *wrapper, jsid id, #define SCSOW FilteringWrapper #define XOW FilteringWrapper, \ CrossOriginAccessiblePropertiesOnly> -#define PXOW FilteringWrapper #define DXOW FilteringWrapper #define NNXOW FilteringWrapper 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; diff --git a/js/xpconnect/wrappers/WrapperFactory.cpp b/js/xpconnect/wrappers/WrapperFactory.cpp index df649d6fe5c..ac4b7733127 100644 --- a/js/xpconnect/wrappers/WrapperFactory.cpp +++ b/js/xpconnect/wrappers/WrapperFactory.cpp @@ -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 Xray; wrapper = &Xray::singleton; @@ -356,8 +353,6 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO wrapper = &FilteringWrapper::singleton; } else if (mozilla::dom::IsDOMObject(obj)) { wrapper = &FilteringWrapper::singleton; - } else if (mozilla::dom::oldproxybindings::instanceIsProxy(obj)) { - wrapper = &FilteringWrapper::singleton; } else if (IsComponentsObject(obj)) { wrapper = &FilteringWrapper::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 Xray; wrapper = &Xray::singleton; @@ -441,9 +434,6 @@ WrapperFactory::Rewrap(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSO } else if (type == XrayForDOMObject) { wrapper = &FilteringWrapper::singleton; - } else if (type == XrayForDOMProxyObject) { - wrapper = &FilteringWrapper::singleton; } else { typedef XrayWrapper Xray; @@ -571,8 +561,6 @@ WrapperFactory::WrapForSameCompartmentXray(JSContext *cx, JSObject *obj) Wrapper *wrapper = NULL; if (type == XrayForWrappedNative) wrapper = &XrayWrapper::singleton; - else if (type == XrayForDOMProxyObject) - wrapper = &XrayWrapper::singleton; else if (type == XrayForDOMObject) wrapper = &XrayWrapper::singleton; else diff --git a/js/xpconnect/wrappers/XrayWrapper.cpp b/js/xpconnect/wrappers/XrayWrapper.cpp index 62790ccbaa7..37296ef2a30 100644 --- a/js/xpconnect/wrappers/XrayWrapper.cpp +++ b/js/xpconnect/wrappers/XrayWrapper.cpp @@ -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 -template <> XRAY XRAY::singleton(0); -template class XRAY; -#undef XRAY - #define XRAY XrayWrapper 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 -template <> XRAY XRAY::singleton(0); -template class XRAY; -#undef XRAY - #define XRAY XrayWrapper template <> XRAY XRAY::singleton(0); template class XRAY; diff --git a/js/xpconnect/wrappers/XrayWrapper.h b/js/xpconnect/wrappers/XrayWrapper.h index 16a969fadff..f93c15eed75 100644 --- a/js/xpconnect/wrappers/XrayWrapper.h +++ b/js/xpconnect/wrappers/XrayWrapper.h @@ -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 XrayProxy; typedef XrayWrapper XrayDOM; class SandboxProxyHandler : public js::IndirectWrapper { diff --git a/layout/base/nsChildIterator.h b/layout/base/nsChildIterator.h index 611aa25ae41..aa1da7f010b 100644 --- a/layout/base/nsChildIterator.h +++ b/layout/base/nsChildIterator.h @@ -94,7 +94,7 @@ public: nsIContent* get() const { if (XBLInvolved()) { - return mNodes->GetNodeAt(mIndex); + return mNodes->Item(mIndex); } return mChild; diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 16e9693616a..331bc6ddb2c 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -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()); } diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index bc481862d02..74ed5a57de5 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -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 diff --git a/xpcom/idl-parser/xpidl.py b/xpcom/idl-parser/xpidl.py index 4fc7b4473fa..5e902d568b5 100644 --- a/xpcom/idl-parser/xpidl.py +++ b/xpcom/idl-parser/xpidl.py @@ -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)